From e0d1a5310366d8855d5f5ceae3040935173a7a4e Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Tue, 19 Jan 2016 18:56:49 -0500 Subject: [PATCH] reorganize --- Makefile | 79 ++++++++++++++++++ README.md | 11 ++- git-vendor => bin/git-vendor | 0 etc/bash_completion.sh | 4 + man/git-vendor.1 | 106 +++++++++++++++++++++++ man/git-vendor.1.html | 158 +++++++++++++++++++++++++++++++++++ man/git-vendor.md | 71 ++++++++++++++++ 7 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 Makefile rename git-vendor => bin/git-vendor (100%) create mode 100755 etc/bash_completion.sh create mode 100644 man/git-vendor.1 create mode 100644 man/git-vendor.1.html create mode 100644 man/git-vendor.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d3c91d6 --- /dev/null +++ b/Makefile @@ -0,0 +1,79 @@ +# Majority of this script was borrowed from git-extra: +# https://github.com/tj/git-extras/blob/98d0d8c642ea2643f513bc41fcb9dd3078cf2e59/Makefile +PREFIX ?= /usr/local +BINPREFIX ?= "$(PREFIX)/bin" +MANPREFIX ?= "$(PREFIX)/share/man/man1" +SYSCONFDIR ?= $(PREFIX)/etc +BINS = $(wildcard bin/git-*) +MANS = $(wildcard man/git-*.md) +MAN_HTML = $(MANS:.md=.html) +MAN_PAGES = $(MANS:.md=.1) + +COMMANDS = $(subst bin/, , $(BINS)) + +default: install + +docs: $(MAN_HTML) $(MAN_PAGES) + +install: + @mkdir -p $(DESTDIR)$(MANPREFIX) + @mkdir -p $(DESTDIR)$(BINPREFIX) + @echo "... installing bins to $(DESTDIR)$(BINPREFIX)" + @echo "... installing man pages to $(DESTDIR)$(MANPREFIX)" + $(eval TEMPFILE := $(shell mktemp -q $${TMPDIR:-/tmp}/git-vendor.XXXXXX 2>/dev/null || mktemp -q)) + @# chmod from rw-------(default) to rwxrwxr-x, so that users can exec the scripts + @chmod 775 $(TEMPFILE) + $(eval EXISTED_ALIASES := $(shell \ + git config --get-regexp 'alias.*' | awk '{print "git-" substr($$1, 7)}')) + @$(foreach COMMAND, $(COMMANDS), \ + disable=''; \ + if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \ + read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \ + test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \ + fi; \ + if test -z "$$disable"; then \ + echo "... installing $(COMMAND)"; \ + cat bin/$(COMMAND) > $(TEMPFILE); \ + cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ + fi; \ + ) + @if [ -z "$(wildcard man/git-*.1)" ]; then \ + echo "WARNING: man pages not created, use 'make docs' (which requires 'ronn' ruby lib)"; \ + else \ + cp -f man/git-*.1 $(DESTDIR)$(MANPREFIX); \ + echo "cp -f man/git-*.1 $(DESTDIR)$(MANPREFIX)"; \ + fi + @mkdir -p $(DESTDIR)$(SYSCONFDIR)/bash_completion.d + cp -f etc/bash_completion.sh $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/git-vendor + +man/%.html: man/%.md + ronn \ + --manual "Git Vendor" \ + --html \ + --pipe \ + $< > $@ + +man/%.1: man/%.md + ronn -r \ + --manual "Git Vendor" \ + --pipe \ + $< > $@ + +uninstall: + @$(foreach BIN, $(BINS), \ + echo "... uninstalling $(DESTDIR)$(BINPREFIX)/$(notdir $(BIN))"; \ + rm -f $(DESTDIR)$(BINPREFIX)/$(notdir $(BIN)); \ + ) + @$(foreach MAN, $(MAN_PAGES), \ + echo "... uninstalling $(DESTDIR)$(MANPREFIX)/$(notdir $(MAN))"; \ + rm -f $(DESTDIR)$(MANPREFIX)/$(notdir $(MAN)); \ + ) + rm -f $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/git-vendor + +clean: docclean + +docclean: + rm -f man/*.1 + rm -f man/*.html + +.PHONY: default docs clean docclean install uninstall diff --git a/README.md b/README.md index c150803..8a5eb86 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,17 @@ A work in progress git command for managing golang vendor dependencies. * `git vendor update ` - update a vendored dependency to ``. ## Installation +Manually: + +```bash +git clone https://github.com/brettlangdon/git-vendor +cd ./git-vendor +make +``` + +One-liner: ```bash -(wget -O /usr/local/bin/git-vendor https://raw.githubusercontent.com/brettlangdon/git-vendor/master/git-vendor && chmod +x /usr/local/bin/git-vendor) +curl -sSL https://raw.githubusercontent.com/brettlangdon/git-vendor/master/install.sh | sudo bash /dev/stdin ``` ## Example diff --git a/git-vendor b/bin/git-vendor similarity index 100% rename from git-vendor rename to bin/git-vendor diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh new file mode 100755 index 0000000..8db8d06 --- /dev/null +++ b/etc/bash_completion.sh @@ -0,0 +1,4 @@ +_git_vendor() +{ + __gitcomp "add list update" +} diff --git a/man/git-vendor.1 b/man/git-vendor.1 new file mode 100644 index 0000000..e8936cb --- /dev/null +++ b/man/git-vendor.1 @@ -0,0 +1,106 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-VENDOR" "1" "January 2016" "" "" +. +.SH "NAME" +\fBgit\-vendor\fR \- manage vendored dependency subtrees +. +.SH "SYNOPSIS" +\fBgit\-vendor add \fR +. +.P +\fBgit\-vendor list\fR +. +.P +\fBgit\-vendor update \fR +. +.SH "DESCRIPTION" +Manage any repository dependencies under \fB/vendor/\fR with \fBgit\-subtree\fR\. +. +.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\. +. +.SH "COMMANDS" +add +. +.P +Add a new vendored dependency +. +.P +list +. +.P +List all existing vendored dependencies and their current version +. +.P +update +. +.P +Update the vendored dependency to a different version +. +.SH "OPTIONS" + +. +.P +The repository url to vendor\. e\.g\. \fBhttps://github\.com//\fR (supports \fBhttp://\fR, \fBhttps://\fR \fBgit://\fR and \fBgit@\fR protocols)\. +. +.P + +. +.P +The ref to vendor\. e\.g\. \fBmaster\fR, \fBv1\.0\.2\fR, etc +. +.P + +. +.P +The vendor directory for the dependency\. e\.g\. \fBvendor/github\.com//\fR\. +. +.SH "EXAMPLES" +Adding a new dependency: +. +.IP "" 4 +. +.nf + +$ git vendor add https://github\.com/brettlangdon/forge v0\.1\.4 +. +.fi +. +.IP "" 0 +. +.P +Updating an existing dependency: +. +.IP "" 4 +. +.nf + +$ git vendor update vendor/github\.com/brettlangdon/forge v0\.1\.7 +. +.fi +. +.IP "" 0 +. +.P +List all existing dependencies: +. +.IP "" 4 +. +.nf + +$ git vendor list +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Written by Brett Langdon \fIme@brett\.is\fR +. +.SH "REPORTING BUGS" +<\fIhttps://github\.com/brettlangdon/git\-vendor/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/brettlangdon/git\-vendor\fR> diff --git a/man/git-vendor.1.html b/man/git-vendor.1.html new file mode 100644 index 0000000..f8a9cdd --- /dev/null +++ b/man/git-vendor.1.html @@ -0,0 +1,158 @@ + + + + + + git-vendor(1) - manage vendored dependency subtrees + + + + +
+ + + +
    +
  1. git-vendor(1)
  2. +
  3. +
  4. git-vendor(1)
  5. +
+ +

NAME

+

+ git-vendor - manage vendored dependency subtrees +

+ +

SYNOPSIS

+ +

git-vendor add <repository> <ref>

+ +

git-vendor list

+ +

git-vendor update <dir> <ref>

+ +

DESCRIPTION

+ +

Manage any repository dependencies under /vendor/<repository> with git-subtree.

+ +

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.

+ +

COMMANDS

+ +

add <repository> <ref>

+ +

Add a new vendored dependency

+ +

list

+ +

List all existing vendored dependencies and their current version

+ +

update <dir> <ref>

+ +

Update the vendored dependency to a different version

+ +

OPTIONS

+ +

<repository>

+ +

The repository url to vendor. e.g. https://github.com/<username>/<repo-name> (supports http://, https:// git:// and git@ protocols).

+ +

<ref>

+ +

The ref to vendor. e.g. master, v1.0.2, etc

+ +

<dir>

+ +

The vendor directory for the dependency. e.g. vendor/github.com/<username>/<repo-name>.

+ +

EXAMPLES

+ +

Adding a new dependency:

+ +
$ git vendor add https://github.com/brettlangdon/forge v0.1.4
+
+ +

Updating an existing dependency:

+ +
$ git vendor update vendor/github.com/brettlangdon/forge v0.1.7
+
+ +

List all existing dependencies:

+ +
$ git vendor list
+
+ +

AUTHOR

+ +

Written by Brett Langdon me@brett.is

+ +

REPORTING BUGS

+ +

<https://github.com/brettlangdon/git-vendor/issues>

+ +

SEE ALSO

+ +

<https://github.com/brettlangdon/git-vendor>

+ + +
    +
  1. +
  2. January 2016
  3. +
  4. git-vendor(1)
  5. +
+ +
+ + diff --git a/man/git-vendor.md b/man/git-vendor.md new file mode 100644 index 0000000..3c6e23a --- /dev/null +++ b/man/git-vendor.md @@ -0,0 +1,71 @@ +git-vendor(1) -- manage vendored dependency subtrees +================================ + +## SYNOPSIS + +`git-vendor add ` + +`git-vendor list` + +`git-vendor update ` + +## DESCRIPTION + + Manage any repository dependencies under `/vendor/` with `git-subtree`. + + `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. + +## COMMANDS + + add <repository> <ref> + + Add a new vendored dependency + + list + + List all existing vendored dependencies and their current version + + update <dir> <ref> + + Update the vendored dependency to a different version + + +## OPTIONS + + <repository> + + The repository url to vendor. e.g. `https://github.com//` (supports `http://`, `https://` `git://` and `git@` protocols). + + <ref> + + The ref to vendor. e.g. `master`, `v1.0.2`, etc + + <dir> + + The vendor directory for the dependency. e.g. `vendor/github.com//`. + +## EXAMPLES + + Adding a new dependency: + + $ git vendor add https://github.com/brettlangdon/forge v0.1.4 + + Updating an existing dependency: + + $ git vendor update vendor/github.com/brettlangdon/forge v0.1.7 + + List all existing dependencies: + + $ git vendor list + +## AUTHOR + +Written by Brett Langdon + +## REPORTING BUGS + +<> + +## SEE ALSO + +<>