diff --git a/README.md b/README.md
index 56b38de..418e46d 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ See https://brettlangdon.github.io/git-vendor for the current MAN page documenta
* `git vendor add [--prefix
] [[]` - add a new vendored dependency.
* `git vendor list []` - list current vendored dependencies, their source, and current vendored ref.
* `git vendor update [][]` - update a vendored dependency.
+* `git vendor push [][]` - push vendored dependency.
## Installation
Manually:
diff --git a/bin/git-vendor b/bin/git-vendor
index 373bf52..bbda812 100755
--- a/bin/git-vendor
+++ b/bin/git-vendor
@@ -13,6 +13,7 @@ Usage:
git vendor list []
git vendor remove
git vendor update [][]
+ git vendor push [][]
EOF
}
@@ -27,7 +28,7 @@ require_work_tree
command="$1"
shift
case "$command" in
- "add"|"list"|"remove"|"update") ;;
+ "add"|"list"|"remove"|"update"|"push") ;;
*) >&2 echo "error: unknown command \"$command\"" && _usage && exit 1 ;;
esac
@@ -207,6 +208,46 @@ git-vendor-ref: $ref
done
}
+cmd_push()
+{
+ require_clean_work_tree
+ name="$1"
+ ref="master"
+ if [ "$2" != "" ]; then
+ ref="$2"
+ fi
+ if [ $# -lt 1 ]; then
+ die "Incorrect options provided: git vendor push [][]"
+ 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
+
+ # 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
+}
+
cmd_remove()
{
require_clean_work_tree
diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh
index 8db8d06..46c9a75 100755
--- a/etc/bash_completion.sh
+++ b/etc/bash_completion.sh
@@ -1,4 +1,4 @@
_git_vendor()
{
- __gitcomp "add list update"
+ __gitcomp "add list update push"
}
diff --git a/man/git-vendor.1 b/man/git-vendor.1
index b33fb3a..1c9a902 100644
--- a/man/git-vendor.1
+++ b/man/git-vendor.1
@@ -18,6 +18,9 @@
.P
\fBgit\-vendor update [][]\fR
.
+.P
+\fBgit\-vendor push [][]\fR
+.
.SH "DESCRIPTION"
Manage any repository dependencies with \fBgit\-subtree\fR\.
.
@@ -25,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/\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 or \fBupdate\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 \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\.
.
.SH "COMMANDS"
add [\-\-prefix ] [][]
@@ -51,6 +54,12 @@ update ][
.P
Update the vendored dependency to a different version\.
.
+.P
+push ][
+.
+.P
+Push the vendored dependency changes to the source repository\.
+.
.SH "OPTIONS"
\-\-prefix
.
@@ -128,6 +137,32 @@ $ git vendor update forge
.IP "" 0
.
.P
+Pushing changes to the source repository to a (new) branch \fBmy_changes\fR:
+.
+.IP "" 4
+.
+.nf
+
+$ git vendor push forge my_changes
+.
+.fi
+.
+.IP "" 0
+.
+.P
+Pushing changes to the source repository to \fBmaster\fR:
+.
+.IP "" 4
+.
+.nf
+
+$ git vendor push forge
+.
+.fi
+.
+.IP "" 0
+.
+.P
Removing a dependency:
.
.IP "" 4
diff --git a/man/git-vendor.md b/man/git-vendor.md
index 74c319e..df2287d 100644
--- a/man/git-vendor.md
+++ b/man/git-vendor.md
@@ -11,13 +11,15 @@ git-vendor(1) -- manage vendored dependency subtrees
`git-vendor update [][]`
+`git-vendor push [][]`
+
## DESCRIPTION
Manage any repository dependencies with `git-subtree`.
`git-vendor` follows the same vendoring pattern that is used in the Go community. Dependencies are stored under `vendor/`. 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` or `update` 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 `push` any dependencies it has not added, the reason is that `git-vendor` adds special commit messages so that it can track existing dependencies.
## COMMANDS
@@ -37,6 +39,10 @@ git-vendor(1) -- manage vendored dependency subtrees
Update the vendored dependency to a different version.
+ push <dir> <ref>
+
+ Push the vendored dependency changes to the source repository.
+
## OPTIONS
@@ -46,7 +52,7 @@ git-vendor(1) -- manage vendored dependency subtrees
<name>
- A name to provide the vendored dependency to use when listing/updating.
+ A name to provide the vendored dependency to use when listing/updating/pushing.
<repository>
@@ -74,6 +80,14 @@ git-vendor(1) -- manage vendored dependency subtrees
$ git vendor update forge
+ Pushing changes to the source repository to `master`:
+
+ $ git vendor push forge
+
+ Pushing changes to the source repository to a (new) branch my_changes:
+
+ $ git vendor push forge my_changes
+
Removing a dependency:
$ git vendor remove forge
]