From 219c2821595daf2487ff1cd59425dfc8c44de9e6 Mon Sep 17 00:00:00 2001 From: Constantin Bejenaru Date: Mon, 19 Feb 2018 18:11:34 +0200 Subject: [PATCH 1/2] Search and publish matching heads only --- git-subsplit.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/git-subsplit.sh b/git-subsplit.sh index 5c84c3b..bca2d60 100755 --- a/git-subsplit.sh +++ b/git-subsplit.sh @@ -21,6 +21,7 @@ work-dir directory that contains the subsplit working directory options for 'publish' heads= only publish for listed heads instead of all heads +search-heads= search and only publish matching heads instead of all heads (grep pattern) no-heads do not publish any heads tags= only publish for listed tags instead of all tags no-tags do not publish any tags @@ -49,6 +50,7 @@ SPLITS= REPO_URL= WORK_DIR="${PWD}/.subsplit" HEADS= +SEARCH_HEADS= NO_HEADS= TAGS= NO_TAGS= @@ -65,6 +67,7 @@ subsplit_main() -q) QUIET=1 ;; --debug) VERBOSE=1 ;; --heads) HEADS="$1"; shift ;; + --search-heads) SEARCH_HEADS="$1"; shift ;; --no-heads) NO_HEADS=1 ;; --tags) TAGS="$1"; shift ;; --no-tags) NO_TAGS=1 ;; @@ -148,7 +151,7 @@ subsplit_publish() subsplit_update fi - if [ -z "$HEADS" ] && [ -z "$NO_HEADS" ] + if [ -z "$HEADS" ] && [ -z "$NO_HEADS" ] && [ -z "$SEARCH_HEADS" ] then # If heads are not specified and we want heads, discover them. HEADS="$(git ls-remote origin 2>/dev/null | grep "refs/heads/" | cut -f3- -d/)" @@ -159,6 +162,18 @@ subsplit_publish() fi fi + # search for matching heads + if [ ! -z "$SEARCH_HEADS" ] && [ -z "$HEADS" ] && [ -z "$NO_HEADS" ] + then + # If heads are not specified and we want heads, discover them. + HEADS="$(git ls-remote origin 2>/dev/null | grep "refs/heads/" | grep "${SEARCH_HEADS}" | cut -f3- -d/)" + + if [ -n "$VERBOSE" ]; + then + echo "${DEBUG} HEADS=\"${HEADS}\"" + fi + fi + if [ -z "$TAGS" ] && [ -z "$NO_TAGS" ] then # If tags are not specified and we want tags, discover them. From 820e14058d43d08ff14a8fb4912481048f343d13 Mon Sep 17 00:00:00 2001 From: Constantin Bejenaru Date: Mon, 19 Feb 2018 18:16:52 +0200 Subject: [PATCH 2/2] README update to reflect --search-heads usage --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 88699ab..231f260 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,18 @@ branches the upstream repository knows about. Do not sync any heads. +#### --search-heads + +To search for a list of possible heads and publish only the matches. + + --search-heads="refs/heads/master\|refs/heads/develop\|refs/heads/release-" + +The above will only publish branches that are either `master`, `develop` +or any other branch of the form `release-*`. + +[Grep](https://www.gnu.org/savannah-checkouts/gnu/grep/manual/grep.html) patterns will be applied. + + #### --tags=\ To specify a list of tags (instead of letting git-subsplit discover them