Skip to content

Conversation

@icodebuster
Copy link
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.
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
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
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
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
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
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
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.

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
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
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
vanpipy pushed a commit to vanpipy/git-extras that referenced this pull request Sep 14, 2023
* 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]>
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