Improvements to the git-bulk:#1054
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.
Let‘s add a comment that it's dedicated not to quoting the var.
There was a problem hiding this comment.
I did not get you. Could you please elaborate?
Thank you.
There was a problem hiding this comment.
It's intended not to use "$line" here, right?
There was a problem hiding this comment.
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.
@icodebuster
Would you add the explanation as a comment in the code?
There was a problem hiding this comment.
I have added a short comment as an explanation. If you have any alternate comments/suggestions, do let me know.
| 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.
Do we need to use -n "$line" here?
There was a problem hiding this comment.
Yes, you are right, we don't need -n $line. I have updated the code.
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