Skip to content

Improvements to the git-bulk:#1054

Merged
spacewander merged 4 commits intotj:masterfrom
icodebuster:git-bulk-enhacement
Jul 7, 2023
Merged

Improvements to the git-bulk:#1054
spacewander merged 4 commits intotj:masterfrom
icodebuster:git-bulk-enhacement

Conversation

@icodebuster
Copy link
Copy Markdown
Contributor

@icodebuster icodebuster commented Jun 29, 2023

  1. 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.

  2. 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

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.
Comment thread bin/git-bulk Outdated
Comment thread bin/git-bulk
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;
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

Comment thread 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
Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

@spacewander spacewander merged commit d7fb449 into tj:master Jul 7, 2023
@icodebuster icodebuster deleted the git-bulk-enhacement branch July 21, 2023 19:06
@icodebuster icodebuster changed the title I have made two improvements to the git-bulk: Improvements to the git-bulk: Jul 21, 2023
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