-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Implement git-get command
#1045
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
f38650e to
20631d5
Compare
man/git-get.md
Outdated
|
|
||
| ## EXAMPLES | ||
|
|
||
| $ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake' |
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 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?
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.
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.
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 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` |
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.
What about using a git config like the other scripts?
For example,
Line 62 in f5bcbe5
| remote_pref=${2:-$(git config --get git-extras.pr.remote)} |
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.
Yeah that's probably better
| @@ -0,0 +1,35 @@ | |||
| #!/usr/bin/env bash | |||
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 this cmd in https://github.com/tj/git-extras/blob/master/not_need_git_repo
|
Made those changes 👍 |
Commands.md
Outdated
| ## git get | ||
| Clone repository into `"$HOME/some-dir/<repository_name>"`: |
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.
Better to mention that this command can clone repo to the configured path, as git clone already support cloning to a specific path.
not_need_git_repo
Outdated
| git-fork | ||
| git-setup | ||
| git-standup | ||
| git-get |
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.
Please put it in alphabetical order
aebfef8 to
2493f99
Compare
|
👍 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" |
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.
Look like we need to add --global here?
|
Sorry for the slow changes, made those improvements 👍 |
bin/git-get
Outdated
| dirname=${dirname##*/} | ||
|
|
||
| mkdir -p "$clone_path" | ||
| git clone "$url" "$clone_path/$dirname" |
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.
Would you add a feature to pass options to git clone or add a TODO comment?
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.
Sounds good 👍
bin/git-get
Outdated
|
|
||
| url=$1 | ||
|
|
||
| if (( $# == 0)); then |
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.
Better to check num of args before assigning to $url
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.
My mistake - it has been fixed now.
bin/git-get
Outdated
| exit 0 | ||
| fi | ||
|
|
||
| if ! shift; then |
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.
Will this shift -h?
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, that has now been fixed.
* 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]>
git get- checkout code in opinionated location #999git-extras updateproduces warnings on OS X #455 (code already fixed)