Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git module clone #287

Merged
merged 4 commits into from
Oct 7, 2020
Merged

Git module clone #287

merged 4 commits into from
Oct 7, 2020

Conversation

paconte
Copy link
Contributor

@paconte paconte commented Sep 22, 2020

This patch add the git-clone functionality at the git module. The patch also fix an existing bug at the git module that throws a UnsopportedOperationException.

@renner renner self-requested a review September 30, 2020 10:04
@renner
Copy link
Member

renner commented Sep 30, 2020

Thanks for this patch, @paconte! I will give it a review soon and hope to have it merged for our next release.

@renner renner modified the milestones: Next, Version 0.18.0 Sep 30, 2020
Copy link
Member

@renner renner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me in general, @paconte, just one question added and maybe indentation in the example code could be adjusted before merge (I wonder why checkstyle didn't find that)?

Comment on lines 33 to 34
// Init the client
SaltClient client =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there is some tab characters here and indentation is a bit off in line 34 and below in line 51, maybe this could be adjusted before merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 4bf414e

@@ -43,9 +44,32 @@ private Git() { }

public static LocalCall<Boolean> branch(String cwd, String branch,
String opts, String gitOpts, Optional<String> user) {
List<String> args = Arrays.asList(cwd, branch, opts, gitOpts);
List<String> args = new ArrayList<>(Arrays.asList(cwd, branch, opts, gitOpts));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this would be needed (here and above), wouldn't Arrays.asList() already create and return a list of strings as List<String>?

Copy link
Contributor Author

@paconte paconte Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. It returns a list of strings as List<String>. However the size of the list is fixed, this will not allow us to add other arguments to the list. Below the documentation of the method:


/**
     * Returns a fixed-size list backed by the specified array.  (Changes to
     * the returned list "write through" to the array.)  This method acts
     * as bridge between array-based and collection-based APIs, in
     * combination with {@link Collection#toArray}.  The returned list is
     * serializable and implements {@link RandomAccess}.
     *
     * <p>This method also provides a convenient way to create a fixed-size
     * list initialized to contain several elements:
     * <pre>
     *     List&lt;String&gt; stooges = Arrays.asList("Larry", "Moe", "Curly");
     * </pre>
     *
     * @param <T> the class of the objects in the array
     * @param a the array by which the list will be backed
     * @return a list view of the specified array
     */
    @SafeVarargs
    @SuppressWarnings("varargs")
    public static <T> List<T> asList(T... a) {
        return new ArrayList<>(a);
    }

If you add an element to that list, the application will throw an Exception. The current code actually send an exception, maybe it was not well tested. This is not the only line of code where this happens, so I made that change on in different places of the git module. See: 2f9c98a

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it makes sense!

@renner renner merged commit 212b06f into SUSE:master Oct 7, 2020
@renner
Copy link
Member

renner commented Oct 7, 2020

Merged for the upcoming 0.18 release. Thanks again, @paconte!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants