-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f4a338f
feat: Add `git-get` command
hyperupcall b063719
Update Commands.md
hyperupcall 2e88438
fix: Use Git config to store value
hyperupcall dbdc29d
improve `git-get` description
hyperupcall 160bce1
fix: Add `--global` to git invocation
hyperupcall 93055f9
Merge branch 'master' into h-git-get
hyperupcall 18aa320
Merge branch 'master' into h-git-get
hyperupcall fbb95a6
Enable passing options to `git clone`
hyperupcall 3458e98
fix: Ordering of checks
hyperupcall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
_usage() { | ||
printf '%s\n' "usage: ${0##*/} <url> | ||
usage: ${0##*/} --help | ||
|
||
Clone a repository in a particular directory." | ||
} | ||
|
||
if (( $# == 0 )); then | ||
_usage | ||
exit 0 | ||
fi | ||
|
||
for arg; do | ||
if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then | ||
_usage | ||
exit 0 | ||
fi | ||
done | ||
|
||
url=$1 | ||
if ! shift; then | ||
printf 'ERROR: Failed to shift' >&2 | ||
exit 1 | ||
fi | ||
|
||
clone_path=$(git config --get git-extras.get.clone-path) | ||
|
||
if [ -z "$clone_path" ]; then | ||
printf 'ERROR: %s\n' "Git configuration key 'git-extras.get.clone-path' must be set to a directory to clone under" >&2 | ||
exit 1 | ||
fi | ||
|
||
dirname=${url%/} | ||
dirname=${url%.git} | ||
dirname=${dirname##*/} | ||
|
||
mkdir -p "$clone_path" | ||
git clone "$url" "$clone_path/$dirname" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.\" generated with Ronn-NG/v0.9.1 | ||
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 | ||
.TH "GIT\-GET" "1" "May 2023" "" "Git Extras" | ||
.SH "NAME" | ||
\fBgit\-get\fR \- Clone a Git repository under a directory | ||
.SH "SYNOPSIS" | ||
\fBgit\-get\fR | ||
.SH "DESCRIPTION" | ||
Clones a Git repository under the directory specified by the Git configuration \fBgit\-extras\.get\.clone\-path\fR | ||
.SH "EXAMPLES" | ||
.nf | ||
$ git config \-\-add git\-extras\.get\.clone\-path "$HOME/some\-dir" | ||
$ git get 'https://github\.com/hyperupcall/bake' | ||
Cloning into '/home/<user>/some\-dir/bake'\|\.\|\.\|\. | ||
remote: Enumerating objects: 1199, done\. | ||
remote: Counting objects: 100% (378/378), done\. | ||
remote: Compressing objects: 100% (174/174), done\. | ||
remote: Total 1199 (delta 163), reused 357 (delta 146), pack\-reused 821 | ||
Receiving objects: 100% (1199/1199), 3\.05 MiB | 9\.85 MiB/s, done\. | ||
Resolving deltas: 100% (515/515), done\. | ||
$ | ||
.fi | ||
.SH "AUTHOR" | ||
Written by Edwin Kofler <\fIedwin@kofler\.dev\fR> | ||
.SH "REPORTING BUGS" | ||
<\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
.SH "SEE ALSO" | ||
<\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
git-get(1) -- Clone a Git repository under a configured directory | ||
================================================= | ||
|
||
## SYNOPSIS | ||
|
||
`git-get` | ||
|
||
## DESCRIPTION | ||
|
||
Clones a Git repository under the directory specified by the Git configuration `git-extras.get.clone-path` | ||
|
||
## EXAMPLES | ||
|
||
$ git config --add git-extras.get.clone-path "$HOME/some-dir" | ||
$ git get 'https://github.com/hyperupcall/bake' | ||
Cloning into '/home/<user>/some-dir/bake'... | ||
remote: Enumerating objects: 1199, done. | ||
remote: Counting objects: 100% (378/378), done. | ||
remote: Compressing objects: 100% (174/174), done. | ||
remote: Total 1199 (delta 163), reused 357 (delta 146), pack-reused 821 | ||
Receiving objects: 100% (1199/1199), 3.05 MiB | 9.85 MiB/s, done. | ||
Resolving deltas: 100% (515/515), done. | ||
$ | ||
|
||
## AUTHOR | ||
|
||
Written by Edwin Kofler <<[email protected]>> | ||
|
||
## REPORTING BUGS | ||
|
||
<<https://github.com/tj/git-extras/issues>> | ||
|
||
## SEE ALSO | ||
|
||
<<https://github.com/tj/git-extras>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ git-bulk | |
git-extras | ||
git-force-clone | ||
git-fork | ||
git-get | ||
git-ignore | ||
git-setup | ||
git-standup |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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