-
Notifications
You must be signed in to change notification settings - Fork 95
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
Git module clone #287
Conversation
Thanks for this patch, @paconte! I will give it a review soon and hope to have it merged for our next release. |
There was a problem hiding this 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)?
// Init the client | ||
SaltClient client = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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>
?
There was a problem hiding this comment.
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<String> 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it makes sense!
Merged for the upcoming 0.18 release. Thanks again, @paconte! |
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.