From 4717e15a9d686ba9e77d77f401e7a069ecbc7b26 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Mon, 18 Jan 2016 20:42:49 -0500 Subject: [PATCH] initial prototype of 'git vendor add' --- git-vendor.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 git-vendor.sh diff --git a/git-vendor.sh b/git-vendor.sh new file mode 100755 index 0000000..c2a9e0a --- /dev/null +++ b/git-vendor.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# +# git-vendor.sh: manage vendored repos via git-subtree +# +# Copyright (C) 2016 Brett Langdon +# +if [ $# -eq 0 ]; +then + set -- -h +fi + +OPTS_SPEC="\ +git vendor add +git vendor list +git vendor update +-- +" +eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" + +PATH=$PATH:$(git --exec-path) +. git-sh-setup + +require_work_tree + +while [ $# -gt 0 ]; do + opt="$1" + shift + case "$opt" in + --) break ;; + *) die "Unexpected option: $opt" ;; + esac +done + +command="$1" +shift +case "$command" in + add|list|update) ;; + *) die "Unknown command '$command'" ;; +esac + +cmd_add() +{ + repository="$1" + ref="$2" + if [ $# -ne 2 ]; + then + die "Incorrect options provided: git vendor add " + fi + + dir="vendor/$(echo "$repository" | sed -E 's/^[a-zA-Z]+((:\/\/)|@)//' | sed 's/:/\//' | sed -E 's/\.git$//')" + message="\ +Add '$dir/' from '$repository $ref' + +git-subtree-repository: $repository +git-subtree-ref: $ref +" + git subtree add --prefix "$dir" --message "$message" "$repository" "$ref" +} + +cmd_list() +{ + die "Not implemented" +} + +cmd_update() +{ + die "Not implemented" +} + +"cmd_$command" "$@"