Skip to content

feat: Implement git-get command#1045

Merged
spacewander merged 9 commits intotj:masterfrom
hyperupcall:h-git-get
Aug 12, 2023
Merged

feat: Implement git-get command#1045
spacewander merged 9 commits intotj:masterfrom
hyperupcall:h-git-get

Conversation

@hyperupcall
Copy link
Copy Markdown
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
Comment thread Commands.md Outdated
Comment thread man/git-get.md Outdated

## EXAMPLES

$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake'
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 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
Copy Markdown
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
Copy Markdown
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]>
Comment thread 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
Copy Markdown
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
Copy Markdown
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

Comment thread bin/git-get
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
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.

@hyperupcall
Copy link
Copy Markdown
Collaborator Author

Made those changes 👍

Comment thread Commands.md Outdated

## git get

Clone repository into `"$HOME/some-dir/<repository_name>"`:
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.

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

Comment thread not_need_git_repo Outdated
git-fork
git-setup
git-standup
git-get
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.

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
Copy Markdown
Collaborator Author

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

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

Sorry for the slow changes, made those improvements 👍

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

mkdir -p "$clone_path"
git clone "$url" "$clone_path/$dirname"
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.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good 👍

Comment thread bin/git-get Outdated

url=$1

if (( $# == 0)); then
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.

Better to check num of args before assigning to $url

Copy link
Copy Markdown
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.

Comment thread bin/git-get Outdated
exit 0
fi

if ! shift; then
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.

Will this shift -h?

Copy link
Copy Markdown
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.

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.

g git get - checkout code in opinionated location new system-branch git-extras update produces warnings on OS X

2 participants