-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improvements to the git-bulk: #1054
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
Conversation
1. Previously, if the "repository.txt" file did not end with a blank line, only three out of four repositories were cloned. This limitation has been fixed. 2. Now, there is support for cloning repositories into custom folder names when using the "repository.txt" file.
| while read -r line; do git clone "$line"; done < "$source"; | ||
| while IFS= read -r line || [[ -n $line ]]; do | ||
| if [ -n "$line" ]; then | ||
| git clone $line; |
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.
Let‘s add a comment that it's dedicated not to quoting the var.
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 did not get you. Could you please elaborate?
Thank you.
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's intended not to use "$line" here, right?
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.
If double quotes are used, the resulting git clone command will be:
git clone "https://host-of-git/repo-1.git Repo-1-Code"
This command may result in an invalid URL since the repository URL and the destination folder are enclosed in double quotes.
However, if the double quotes are removed, the git clone command will be:
git clone https://host-of-git/repo-1.git Repo-1-Code
By removing the double quotes, the command will create a separate folder named "Repo-1-Code" for the cloned repository, which is the enhancement I am suggesting.
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.
@icodebuster
Would you add the explanation as a comment in the code?
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 have added a short comment as an explanation. If you have any alternate comments/suggestions, do let me know.
bin/git-bulk
Outdated
| if [ -f "$source" ]; then | ||
| pushd "$wsdir" > /dev/null | ||
| while read -r line; do git clone "$line"; done < "$source"; | ||
| while IFS= read -r line || [[ -n $line ]]; do |
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.
Do we need to use -n "$line" here?
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, we don't need -n $line. I have updated the code.
* I have made two improvements to the git-bulk: 1. Previously, if the "repository.txt" file did not end with a blank line, only three out of four repositories were cloned. This limitation has been fixed. 2. Now, there is support for cloning repositories into custom folder names when using the "repository.txt" file. * Corrected the code indentation. * removed the extra condition to check is the line was empty or not. * Updated the comment for the new changes in the code. --------- Co-authored-by: Jobin Kurian <[email protected]>
Previously, if the "repository.txt" file did not end with a blank line, the last entry in the list of repositories was omitted during the cloning process. This limitation has been addressed, and now all repositories listed in the file, including the last one, will be successfully cloned regardless of whether the file ends with a blank line or not.
There is support for cloning repositories into custom folder names when using the "repository.txt" file.
repositories.txt
--------------------------------------------------------------------
https://host-of-git/repo-1.git Repo-1-Code
https://host-of-git/repo-2.git Repo-2-Code
https://host-of-git/repo-3.git Repo-3-Code