mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 16:16:37 +08:00
ci: make canary
This commit is contained in:
@@ -110,30 +110,40 @@ dev:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Merge local feat into canary, push canary, then restore the previous branch.
|
# Merge the current local branch into canary, push canary, then restore it.
|
||||||
# Does not leave the working tree on canary when started from another branch.
|
# Dirty worktrees are auto-stashed and restored after the operation.
|
||||||
canary:
|
canary:
|
||||||
@set -e; \
|
@set -e; \
|
||||||
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
|
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
|
||||||
echo "Error: not a git repository"; exit 1; \
|
echo "Error: not a git repository"; exit 1; \
|
||||||
fi; \
|
fi; \
|
||||||
if [ -n "$$(git status --porcelain)" ]; then \
|
|
||||||
echo "Error: working tree is dirty; commit or stash first"; exit 1; \
|
|
||||||
fi; \
|
|
||||||
orig=$$(git rev-parse --abbrev-ref HEAD); \
|
orig=$$(git rev-parse --abbrev-ref HEAD); \
|
||||||
if [ "$$orig" = "HEAD" ]; then \
|
if [ "$$orig" = "HEAD" ]; then \
|
||||||
echo "Error: detached HEAD; checkout a branch first"; exit 1; \
|
echo "Error: detached HEAD; checkout a branch first"; exit 1; \
|
||||||
fi; \
|
fi; \
|
||||||
|
if [ "$$orig" = "canary" ]; then \
|
||||||
|
echo "Error: already on canary; checkout a source branch first"; exit 1; \
|
||||||
|
fi; \
|
||||||
|
stashed=0; \
|
||||||
|
if [ -n "$$(git status --porcelain)" ]; then \
|
||||||
|
echo "Working tree is dirty; stashing local changes..."; \
|
||||||
|
git stash push -u -m "make canary auto-stash from $$orig"; \
|
||||||
|
stashed=1; \
|
||||||
|
fi; \
|
||||||
cleanup() { \
|
cleanup() { \
|
||||||
cur=$$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true); \
|
cur=$$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true); \
|
||||||
if [ "$$cur" != "$$orig" ]; then \
|
if [ "$$cur" != "$$orig" ]; then \
|
||||||
echo "Restoring branch $$orig..."; \
|
echo "Restoring branch $$orig..."; \
|
||||||
git checkout -q "$$orig"; \
|
git checkout -q "$$orig"; \
|
||||||
fi; \
|
fi; \
|
||||||
|
if [ "$$stashed" = "1" ]; then \
|
||||||
|
echo "Restoring stashed local changes..."; \
|
||||||
|
git stash pop; \
|
||||||
|
fi; \
|
||||||
}; \
|
}; \
|
||||||
trap cleanup EXIT; \
|
trap cleanup EXIT; \
|
||||||
echo "Merging feat -> canary (started from $$orig)..."; \
|
echo "Merging $$orig -> canary..."; \
|
||||||
git checkout canary; \
|
git checkout canary; \
|
||||||
git merge --no-edit feat; \
|
git merge --no-edit "$$orig"; \
|
||||||
git push -u origin canary; \
|
git push -u origin canary; \
|
||||||
echo "Done: feat merged into canary and pushed."
|
echo "Done: $$orig merged into canary and pushed."
|
||||||
|
|||||||
Reference in New Issue
Block a user