-
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
Changes from 2 commits
f4a338f
b063719
2e88438
dbdc29d
160bce1
93055f9
18aa320
fbb95a6
3458e98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
_usage() { | ||
printf '%s\n' "usage: ${0##*/} <url> | ||
usage: ${0##*/} --help | ||
Clone a repository in a particular directory." | ||
} | ||
|
||
url=$1 | ||
|
||
if (( $# == 0)); then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. My mistake - it has been fixed now. |
||
_usage | ||
exit 0 | ||
fi | ||
|
||
for arg; do | ||
if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then | ||
_usage | ||
exit 0 | ||
fi | ||
done | ||
|
||
|
||
if [ -z "$GIT_EXTRA_DEFAULT_CLONE_PATH" ]; then | ||
printf 'ERROR: %s\n' "Environment variable 'GIT_EXTRA_DEFAULT_CLONE_PATH' must be set to a directory to clone under" >&2 | ||
exit 1 | ||
fi | ||
|
||
dirname=${url%/} | ||
dirname=${url%.git} | ||
dirname=${dirname##*/} | ||
|
||
mkdir -p "$GIT_EXTRA_DEFAULT_CLONE_PATH" | ||
git clone "$url" "$GIT_EXTRA_DEFAULT_CLONE_PATH/$dirname" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.\" 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 environment variable \fBGIT_EXTRA_DEFAULT_CLONE_PATH\fR | ||
.SH "EXAMPLES" | ||
.nf | ||
$ GIT_EXTRA_DEFAULT_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.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||
git-get(1) -- Clone a Git repository under a directory | ||||
================================================= | ||||
|
||||
## SYNOPSIS | ||||
|
||||
`git-get` | ||||
|
||||
## 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 commentThe reason will be displayed to describe this comment to others. Learn more. What about using a git config like the other scripts? Line 62 in f5bcbe5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's probably better |
||||
|
||||
## 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 commentThe reason will be displayed to describe this comment to others. Learn more. It seems that this feature is not much convenient than There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see |
||||
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>> |
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