Skip to content

Commit 832189e

Browse files
committed
Updated some output of heads and tags and now skips tags that do not exist. closes #4
1 parent 5e8a26a commit 832189e

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

git-subsplit.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,15 @@ subsplit_publish()
159159

160160
for HEAD in $HEADS
161161
do
162+
if ! git show-ref --quiet --verify -- "refs/heads/${HEAD}"
163+
then
164+
say " - skipping head '${HEAD}' (does not exist)"
165+
continue
166+
fi
162167
LOCAL_BRANCH="${REMOTE_NAME}-branch-${HEAD}"
163-
say " - syncing branch ${HEAD}"
168+
say " - syncing branch '${HEAD}'"
164169
git branch -D "$LOCAL_BRANCH" >/dev/null 2>&1
165-
git subtree split -q --prefix="$SUBPATH" --branch="$LOCAL_BRANCH" "origin/${HEAD}" >/dev/null 2>&1
170+
git subtree split -q --prefix="$SUBPATH" --branch="$LOCAL_BRANCH" "origin/${HEAD}" >/dev/null
166171
if [ $? -eq 0 ]
167172
then
168173
PUSH_CMD="git push -q ${DRY_RUN} --force $REMOTE_NAME ${LOCAL_BRANCH}:${HEAD}"
@@ -178,15 +183,23 @@ subsplit_publish()
178183

179184
for TAG in $TAGS
180185
do
186+
if ! git show-ref --quiet --verify -- "refs/tags/${TAG}"
187+
then
188+
say " - skipping tag '${TAG}' (does not exist)"
189+
continue
190+
fi
181191
LOCAL_TAG="${REMOTE_NAME}-tag-${TAG}"
182192
if git branch | grep "${LOCAL_TAG}$" >/dev/null && [ -z "$REBUILD_TAGS" ]
183193
then
184-
say " - skpping tag ${TAG} (already synced)"
194+
say " - skpping tag '${TAG}' (already synced)"
185195
continue
186196
fi
187-
say " - syncing tag ${TAG}"
197+
say " - syncing tag '${TAG}'"
198+
say " - deleting '${LOCAL_TAG}'"
188199
git branch -D "$LOCAL_TAG" >/dev/null 2>&1
189-
git subtree split -q --annotate="${ANNOTATE}" --prefix="$SUBPATH" --branch="$LOCAL_TAG" "$TAG" >/dev/null 2>&1
200+
say " - subtree split for '${TAG}'"
201+
git subtree split -q --annotate="${ANNOTATE}" --prefix="$SUBPATH" --branch="$LOCAL_TAG" "$TAG" >/dev/null
202+
say " - subtree split for '${TAG}' [DONE]"
190203
if [ $? -eq 0 ]
191204
then
192205
PUSH_CMD="git push -q ${DRY_RUN} --force ${REMOTE_NAME} ${LOCAL_TAG}:refs/tags/${TAG}"

0 commit comments

Comments
 (0)