This commit is contained in:
aynic.os
2021-05-17 03:40:02 +02:00
parent 82ce98bb2c
commit 7271c1160f
20 changed files with 125 additions and 180 deletions
+10 -10
View File
@@ -3,7 +3,7 @@
## Check if monorepo is up to date with subrepo. subrepo-push saves the parent commit in .gitrepo
.PHONY: git-diff-subrepo
git-diff-subrepo: infra-base subrepo-check
git-diff-subrepo: myos-base subrepo-check
## Get parent commit in .gitrepo : awk '$1 == "parent" {print $3}' subrepo/.gitrepo
## Get child of parent commit : git rev-list --ancestry-path parent..HEAD |tail -n 1
## Compare child commit with our tree : git diff --quiet child -- subrepo
@@ -12,23 +12,23 @@ git-diff-subrepo: infra-base subrepo-check
$(eval DRYRUN_IGNORE := false)
.PHONY: git-fetch-subrepo
git-fetch-subrepo: infra-base subrepo-check
git-fetch-subrepo: myos-base subrepo-check
$(call exec,git fetch --prune $(REMOTE))
.PHONY: git-stash
git-stash: infra-base git-status
git-stash: myos-base git-status
if [ ! $(STATUS) -eq 0 ]; then \
$(call exec,git stash); \
fi
.PHONY: git-status
git-status: infra-base
git-status: myos-base
$(eval DRYRUN_IGNORE := true)
$(eval STATUS := $(shell $(call exec,git status -uno --porcelain 2>/dev/null |wc -l)))
$(eval DRYRUN_IGNORE := false)
.PHONY: git-unstash
git-unstash: infra-base
git-unstash: myos-base
$(eval STATUS ?= 0)
if [ ! $(STATUS) -eq 0 ]; then \
$(call exec,git stash pop); \
@@ -36,7 +36,7 @@ git-unstash: infra-base
# Create branch $(BRANCH) from upstream/$* branch
.PHONY: branch-create-upstream-%
branch-create-upstream-%: infra-base update-upstream
branch-create-upstream-%: myos-base update-upstream
$(call exec,git fetch --prune upstream)
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1 && echo Unable to create $(BRANCH). || git branch $(BRANCH) upstream/$*)
$(call exec,[ $$(git ls-remote --heads upstream $(BRANCH) |wc -l) -eq 0 ] && git push upstream $(BRANCH) || echo Unable to create branch $(BRANCH) on remote upstream.)
@@ -44,13 +44,13 @@ branch-create-upstream-%: infra-base update-upstream
# Delete branch $(BRANCH)
.PHONY: branch-delete
branch-delete: infra-base update-upstream
branch-delete: myos-base update-upstream
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1 && git branch -d $(BRANCH) || echo Unable to delete branch $(BRANCH).)
$(foreach remote,upstream, $(call exec,[ $$(git ls-remote --heads $(remote) $(BRANCH) |wc -l) -eq 1 ] && git push $(remote) :$(BRANCH) || echo Unable to delete branch $(BRANCH) on remote $(remote).) &&) true
# Merge branch $(BRANCH) into upstream/$* branch
.PHONY: branch-merge-upstream-%
branch-merge-upstream-%: infra-base update-upstream
branch-merge-upstream-%: myos-base update-upstream
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1)
$(call exec,git checkout $(BRANCH))
$(call exec,git pull --ff-only upstream $(BRANCH))
@@ -62,7 +62,7 @@ branch-merge-upstream-%: infra-base update-upstream
# Create $(TAG) tag to reference upstream/$* branch
.PHONY: tag-create-upstream-%
tag-create-upstream-%: infra-base update-upstream
tag-create-upstream-%: myos-base update-upstream
ifneq ($(words $(TAG)),0)
$(call exec,git checkout $*)
$(call exec,git pull --tags --prune upstream $*)
@@ -76,7 +76,7 @@ endif
# Merge tag $(TAG) into upstream/$* branch
.PHONY: tag-merge-upstream-%
tag-merge-upstream-%: infra-base update-upstream
tag-merge-upstream-%: myos-base update-upstream
ifneq ($(words $(TAG)),0)
$(call exec,git fetch --tags -u --prune upstream $*:$*)
$(call exec,git checkout $*)