git scripts

This commit is contained in:
Mayel de Borniol 2022-01-06 10:09:34 +13:00
parent 03a6d8f200
commit b68466402e
2 changed files with 25 additions and 19 deletions

View file

@ -147,9 +147,7 @@ update.app: update.repo ## Update the app and Bonfire extensions in ./deps
@make --no-print-directory mix.remote~updates
update.repo:
git add --all .
git diff-index --quiet HEAD || git commit --all --verbose
git pull --rebase
@chmod +x git-publish.sh && ./git-publish.sh pull
update.deps.bonfire: init mix.remote~bonfire.deps ## Update to the latest Bonfire extensions in ./deps
@ -158,17 +156,14 @@ update.deps.all: ## Update evey single dependency (use with caution)
update.dep~%: ## Update a specify dep (eg. `make update.dep~pointers`)
@make --no-print-directory mix.remote~"deps.update $*"
@chmod +x git-publish.sh
./git-publish.sh $(FORKS_PATH)/$* pull
@chmod +x git-publish.sh && ./git-publish.sh $(FORKS_PATH)/$* pull
#update.forks: git.forks~pull ## Pull the latest commits from all ./forks
update.forks: ## Pull the latest commits from all ./forks
@chmod +x git-publish.sh
find $(FORKS_PATH) -mindepth 1 -maxdepth 1 -type d -exec ./git-publish.sh {} pull \;
@jungle git fetch || echo "Jungle not available, will fetch one by one instead."
@chmod +x git-publish.sh && find $(FORKS_PATH) -mindepth 1 -maxdepth 1 -type d -exec ./git-publish.sh {} maybe-pull \;
update.fork~%: ## Pull the latest commits from all ./forks
@chmod +x git-publish.sh
find $(FORKS_PATH)/$* -mindepth 0 -maxdepth 0 -type d -exec ./git-publish.sh {} pull \;
@chmod +x git-publish.sh && find $(FORKS_PATH)/$* -mindepth 0 -maxdepth 0 -type d -exec ./git-publish.sh {} pull \;
deps.get: mix.remote~deps.get mix~deps.get js.ext.deps.get ## Fetch locked version of non-forked deps
@ -487,5 +482,3 @@ git.merge~%: ## Draft-merge another branch, eg `make git-merge-with-valueflows-a
git.conflicts: ## Find any git conflicts in ./forks
find $(FORKS_PATH) -mindepth 1 -maxdepth 1 -type d -exec echo add {} \; -exec git -C '{}' diff --name-only --diff-filter=U \;
pull:
git pull

View file

@ -1,6 +1,11 @@
#!/bin/bash
DIR="${1:-$PWD}"
function fail {
printf '%s\n' "$1" >&2 ## Send message to stderr.
exit "${2-1}" ## Return a code specified by $2, or 1 by default.
}
echo Checking for changes in $DIR
cd $DIR
@ -19,18 +24,26 @@ then
# if there are changes, commit them (needed before being able to rebase)
git diff-index --quiet HEAD || git commit --verbose --all || echo Skipped...
# fetch and rebase remote changes, or fallback to regular pulling if we skipped commiting
git pull --rebase || git pull
if [[ $2 == 'pull' ]]
then
git fetch
fi
echo Publishing changes!
git push
# merge/rebase local changes
git rebase && echo "Publishing changes!" && git push || fail "Please resolve conflicts before continuing."
else
set -e
#echo No local changes since last run
if [[ $2 == 'pull' ]]
if [[ $2 == 'pull' ]]
then
git pull
git pull --rebase || fail "Please resolve conflicts before continuing."
fi
if [[ $2 == 'maybe-pull' ]]
then
# if jungle is available and we assume fetches were already done
jungle || git pull --rebase || fail "Please resolve conflicts before continuing."
fi
fi