Browse Source

rename push command to upstream and add new optional argument that can override $repository

pull/23/head
Nissim Bendanan 4 years ago
parent
commit
c8f725f9da
5 changed files with 103 additions and 49 deletions
  1. +1
    -1
      README.md
  2. +53
    -33
      bin/git-vendor
  3. +1
    -1
      etc/bash_completion.sh
  4. +33
    -7
      man/git-vendor.1
  5. +15
    -7
      man/git-vendor.md

+ 1
- 1
README.md View File

@ -18,7 +18,7 @@ See https://brettlangdon.github.io/git-vendor for the current MAN page documenta
* `git vendor add [--prefix <dir>] <name> <repository> [<ref>]` - add a new vendored dependency.
* `git vendor list [<name>]` - list current vendored dependencies, their source, and current vendored ref.
* `git vendor update <name> [<ref>]` - update a vendored dependency.
* `git vendor push <name> [<ref>]` - push vendored dependency.
* `git vendor upstream <name> [<ref>] [--repo <repository>]` - share with the upstream vendored dependency.
## Installation
Manually:


+ 53
- 33
bin/git-vendor View File

@ -13,7 +13,7 @@ Usage:
git vendor list [<name>]
git vendor remove <name>
git vendor update <name> [<ref>]
git vendor push <name> [<ref>]
git vendor upstream <name> [<ref>] [--repo <repository>]
EOF
}
@ -28,7 +28,7 @@ require_work_tree
command="$1"
shift
case "$command" in
"add"|"list"|"remove"|"update"|"push") ;;
"add"|"list"|"remove"|"update"|"upstream") ;;
*) >&2 echo "error: unknown command \"$command\"" && _usage && exit 1 ;;
esac
@ -208,44 +208,64 @@ git-vendor-ref: $ref
done
}
cmd_push()
cmd_upstream()
{
require_clean_work_tree
name="$1"
ref="master"
if [ "$2" != "" ]; then
ref="$2"
while [ $# -gt 0 ] ; do
case $1 in
--repo)
repository_arg="$2"
shift # argument value
;;
*)
if [ -z "$name" ]; then
name="$1"
elif [ -z "$ref" ]; then
ref="$1"
fi
;;
esac
shift # current argument
done
if [ -z "$name" ]; then
die "Incorrect options provided: git vendor upstream <name> [<ref>] [--repo <repository>]"
fi
if [ $# -lt 1 ]; then
die "Incorrect options provided: git vendor push <name> [<ref>]"
if [ -z "$ref" ]; then
ref="master"
fi
vendor_git_log_from_name "$name" |
while read a b junk; do
case "$a" in
START) ;;
git-vendor-dir:) dir="$b" ;;
git-vendor-repository:) repository="$b" ;;
git-vendor-ref:) curr_ref="$b" ;;
END)
# Make sure the dependency exists on disk
if [ ! -d "$dir" ]; then
die "Dependency \"$1\" is missing from \"$dir\""
fi
while read a b junk; do
case "$a" in
START) ;;
git-vendor-dir:) dir="$b" ;;
git-vendor-repository:) repository="$b" ;;
END)
# Make sure the dependency exists on disk
if [ ! -d "$dir" ]; then
die "Dependency \"$1\" is missing from \"$dir\""
fi
# And hasn't been renamed
logname=$(vendor_name_from_dir "$dir")
if [ "$name" != "$logname" ]; then
die "Dependency \"$1\" was renamed \"$logname\""
fi
# And hasn't been renamed
logname=$(vendor_name_from_dir "$dir")
if [ "$name" != "$logname" ]; then
die "Dependency \"$1\" was renamed \"$logname\""
fi
if [ ! -z "$repository" ];
then
git subtree push --prefix "$dir" "$repository" "$ref"
break
fi
;;
esac
done
if [ ! -z "$repository_arg" ];
then
# override the reposition read from the commit logs
# with the one read from the command line arguments
repository=$repository_arg
fi
if [ ! -z "$repository" ];
then
git subtree push --prefix "$dir" "$repository" "$ref"
break
fi
;;
esac
done
}
cmd_remove()


+ 1
- 1
etc/bash_completion.sh View File

@ -1,4 +1,4 @@
_git_vendor()
{
__gitcomp "add list update push"
__gitcomp "add list update upstream"
}

+ 33
- 7
man/git-vendor.1 View File

@ -19,7 +19,7 @@
\fBgit\-vendor update <name> [<ref>]\fR
.
.P
\fBgit\-vendor push <name> [<ref>]\fR
\fBgit\-vendor upstream <name> [<ref>]\fR
.
.SH "DESCRIPTION"
Manage any repository dependencies with \fBgit\-subtree\fR\.
@ -28,7 +28,7 @@ Manage any repository dependencies with \fBgit\-subtree\fR\.
\fBgit\-vendor\fR follows the same vendoring pattern that is used in the Go community\. Dependencies are stored under \fBvendor/<repository_uri>\fR\. For example, the dependency of \fBhttps://github\.com/brettlangdon/forge\.git\fR will be stored under \fBvendor/github\.com/brettlangdon/forge\fR by default\.
.
.P
\fBgit\-vendor\fR is unable to \fBlist\fR, \fBupdate\fR or \fBpush\fR any dependencies it has not added, the reason is that \fBgit\-vendor\fR adds special commit messages so that it can track existing dependencies\.
\fBgit\-vendor\fR is unable to \fBlist\fR, \fBupdate\fR or \fBupstream\fR any dependencies it has not added, the reason is that \fBgit\-vendor\fR adds special commit messages so that it can track existing dependencies\.
.
.SH "COMMANDS"
add [\-\-prefix <dir>] <name> <repository> [<ref>]
@ -55,7 +55,7 @@ update <dir> <ref>
Update the vendored dependency to a different version\.
.
.P
push <dir> <ref>
upstream <dir> <ref>
.
.P
Push the vendored dependency changes to the source repository\.
@ -137,26 +137,52 @@ $ git vendor update forge
.IP "" 0
.
.P
Pushing changes to the source repository to a (new) branch \fBmy_changes\fR:
Upstream changes to the source repository to a (new) branch \fBmy_changes\fR:
.
.IP "" 4
.
.nf
$ git vendor push forge my_changes
$ git vendor upstream forge my_changes
.
.fi
.
.IP "" 0
.
.P
Pushing changes to the source repository to \fBmaster\fR:
Upstream changes to the source repository to \fBmaster\fR:
.
.IP "" 4
.
.nf
$ git vendor push forge
$ git vendor upstream forge
.
.fi
.
.IP "" 0
.
.P
Upstream changes to another repository to a (new) branch \fBmy_changes\fR:
.
.IP "" 4
.
.nf
$ git vendor upstream forge my_changes --repo https://github.com/user/another.git
.
.fi
.
.IP "" 0
.
.P
Upstream changes to another repository to \fBmaster\fR:
.
.IP "" 4
.
.nf
$ git vendor upstream forge --repo https://github.com/user/another.git
.
.fi
.


+ 15
- 7
man/git-vendor.md View File

@ -11,7 +11,7 @@ git-vendor(1) -- manage vendored dependency subtrees
`git-vendor update <name> [<ref>]`
`git-vendor push <name> [<ref>]`
`git-vendor upstream <name> [<ref>]`
## DESCRIPTION
@ -19,7 +19,7 @@ git-vendor(1) -- manage vendored dependency subtrees
`git-vendor` follows the same vendoring pattern that is used in the Go community. Dependencies are stored under `vendor/<repository_uri>`. For example, the dependency of `https://github.com/brettlangdon/forge.git` will be stored under `vendor/github.com/brettlangdon/forge` by default.
`git-vendor` is unable to `list`, `update` or `push` any dependencies it has not added, the reason is that `git-vendor` adds special commit messages so that it can track existing dependencies.
`git-vendor` is unable to `list`, `update` or `upstream` any dependencies it has not added, the reason is that `git-vendor` adds special commit messages so that it can track existing dependencies.
## COMMANDS
@ -39,7 +39,7 @@ git-vendor(1) -- manage vendored dependency subtrees
Update the vendored dependency to a different version.
push &lt;dir&gt; &lt;ref&gt;
upstream &lt;dir&gt; &lt;ref&gt;
Push the vendored dependency changes to the source repository.
@ -80,13 +80,21 @@ git-vendor(1) -- manage vendored dependency subtrees
$ git vendor update forge
Pushing changes to the source repository to `master`:
Upstream changes to the source repository to `master`:
$ git vendor push forge
$ git vendor upstream forge
Pushing changes to the source repository to a (new) branch my_changes:
Upstream changes to the source repository to a (new) branch my_changes:
$ git vendor push forge my_changes
$ git vendor upstream forge my_changes
Upstream changes to another repository to `master`:
$ git vendor upstream forge --repo https://github.com/user/another.git
Upstream changes to another repository to a (new) branch my_changes:
$ git vendor upstream forge my_changes --repo https://github.com/user/another.git
Removing a dependency:


Loading…
Cancel
Save