Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for matching branches, not only fixed names #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=\<tags\>

To specify a list of tags (instead of letting git-subsplit discover them
Expand Down
17 changes: 16 additions & 1 deletion git-subsplit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +50,7 @@ SPLITS=
REPO_URL=
WORK_DIR="${PWD}/.subsplit"
HEADS=
SEARCH_HEADS=
NO_HEADS=
TAGS=
NO_TAGS=
Expand All @@ -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 ;;
Expand Down Expand Up @@ -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/)"
Expand All @@ -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.
Expand Down