Skip to content
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

feat: Implement git-get command #1045

Merged
merged 9 commits into from
Aug 12, 2023
Merged

feat: Implement git-get command #1045

merged 9 commits into from
Aug 12, 2023

Conversation

hyperupcall
Copy link
Collaborator

@hyperupcall hyperupcall commented May 17, 2023

@hyperupcall hyperupcall force-pushed the h-git-get branch 7 times, most recently from f38650e to 20631d5 Compare May 17, 2023 02:40
Commands.md Outdated Show resolved Hide resolved
man/git-get.md Outdated

## EXAMPLES

$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this feature is not much convenient than git clone 'https://github.com/hyperupcall/bake' $GIT_EXTRA_DEFAULT_CLONE_PATH/bake. Could you provide some real-world use cases for this tool?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked issue did suggest making a PR, but this change additionally significantly reduces typing.

On some keyboards (like mine), the ~ is either touch to reach, or requires an extra button (Fn+Shift for some 80%s). $HOME is also quite long to type. Besides that, this is a good solution when cloning frequently. It's common to clone repositories (maybe for just sifting through or quickly reading code) to a certain directory, such as ~/Programming/git. I myself have about 50 Git repositories cloned there. Having an actual variable like $GIT_CLONE_DIR is hard to remember and again is on the longer side.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

Co-authored-by: 罗泽轩 <[email protected]>
man/git-get.md Outdated

## DESCRIPTION

Clones a Git repository under the directory specified by the environment variable `GIT_EXTRA_DEFAULT_CLONE_PATH`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using a git config like the other scripts?
For example,

remote_pref=${2:-$(git config --get git-extras.pr.remote)}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's probably better

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyperupcall
Copy link
Collaborator Author

Made those changes 👍

Commands.md Outdated
@@ -889,6 +890,15 @@ Create empty local branch `name`:
$ git fresh-branch docs
```

## git get

Clone repository into `"$HOME/some-dir/<repository_name>"`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to mention that this command can clone repo to the configured path, as git clone already support cloning to a specific path.

@@ -7,3 +7,4 @@ git-force-clone
git-fork
git-setup
git-standup
git-get
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put it in alphabetical order

@hyperupcall hyperupcall force-pushed the h-git-get branch 2 times, most recently from aebfef8 to 2493f99 Compare May 27, 2023 07:44
@hyperupcall
Copy link
Collaborator Author

👍 I added the concept of configured path specifically to the documentation

Commands.md Outdated
Clone repository into a subdirectory of the configured path, `"$HOME/some-dir"`:

```bash
$ git config --add git-extras.get.clone-path "$HOME/some-dir"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look like we need to add --global here?

@hyperupcall
Copy link
Collaborator Author

Sorry for the slow changes, made those improvements 👍

bin/git-get Outdated
dirname=${dirname##*/}

mkdir -p "$clone_path"
git clone "$url" "$clone_path/$dirname"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you add a feature to pass options to git clone or add a TODO comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

bin/git-get Outdated

url=$1

if (( $# == 0)); then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to check num of args before assigning to $url

Copy link
Collaborator Author

@hyperupcall hyperupcall Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake - it has been fixed now.

bin/git-get Outdated
exit 0
fi

if ! shift; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this shift -h?

Copy link
Collaborator Author

@hyperupcall hyperupcall Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that has now been fixed.

@spacewander spacewander merged commit 8af4389 into tj:master Aug 12, 2023
vanpipy pushed a commit to vanpipy/git-extras that referenced this pull request Sep 14, 2023
* feat: Add `git-get` command

* Update Commands.md

Co-authored-by: 罗泽轩 <[email protected]>

* fix: Use Git config to store value

* improve `git-get` description

* fix: Add `--global` to git invocation

* Enable passing options to `git clone`

* fix: Ordering of checks

---------

Co-authored-by: 罗泽轩 <[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
2 participants