gitworkflow
gitworkflow copied to clipboard
Links/scripts to rebuilding next & pu
Link to script to rebuild next
based on topics currently in next
Link to script to rebuild pu
based on topics currently in pu
I have tried to script it, let me know if it's correct or optimizations can be done as I'm not really a bash programmer.
Scenario
- Rebuild
pu
ornext
: topics has new changes or rebased, rebuild integration branch
Script
rebuild.sh
target=$1
ancestor=${2:-master}
backup=pre-rebuild-$target
failed="false"
onFail() { failed="true"; echo "Aborting..."; git reset --hard $backup; git tag -d $backup; }
onSuccess() { echo "Rebuild $target success!"; git tag -d $backup; }
# using `mergedinto` alias, this keeps the merge commit order, but removes dups i.e.
# merge A, merge B, then merge A, becomes merge A, B -- in my experience this works well
# https://gist.github.com/rocketraman/1fdc93feb30aa00f6f3a9d7d732102a9#file-gitconfig-L60
git mergedinto $ancestor..$target > /tmp/branches
git checkout $target
git tag -d $backup
git tag "$backup"
git reset --hard $ancestor; echo "Rebuilding $target starting from $ancestor";
# fish shell syntax
while read x; do
echo "Merging $x"
# mb (merge-branch) is another alias I use to avoid having to pull all the topic branches down locally
# but otherwise this is a simple `merge --no-ff`
# https://gist.github.com/rocketraman/1fdc93feb30aa00f6f3a9d7d732102a9#file-gitconfig-L14
git mb $x || { onFail; break; }
done < /tmp/branches
if [[ "$failed" == "false" ]]; then onSuccess; fi
Usage:
bash rebuild.sh {integration_branch} {ancestor}
-
next
:bash rebuild.sh next
equivalent tobash rebuild.sh next master
-
pu
:bash rebuild.sh pu
equivalent tobash rebuild.sh pu master
I have another version for graduation where it copies all merged topics from an integration branch to target integration branch
Scenarios:
Copy pu
to next
Copy next
to master
Script
rebuildto.sh
target=$1
from=$2
ancestor=${3:-master}
backup=pre-rebuildto-${target}-from-${from}
failed="false"
onFail() { failed="true"; echo "Aborting..."; git reset --hard $backup; git tag -d $backup; }
onSuccess() { echo "Rebuild $target from $from success!"; git tag -d $backup; }
# using `mergedinto` alias, this keeps the merge commit order, but removes dups i.e.
# merge A, merge B, then merge A, becomes merge A, B -- in my experience this works well
# https://gist.github.com/rocketraman/1fdc93feb30aa00f6f3a9d7d732102a9#file-gitconfig-L60
git mergedinto $ancestor..$from > /tmp/branches
git checkout $target
git tag -d $backup
git tag "$backup"
git reset --hard $ancestor; echo "Rebuilding $from to $target starting from $ancestor";
# fish shell syntax
while read x; do
echo "Merging $x"
# mb (merge-branch) is another alias I use to avoid having to pull all the topic branches down locally
# but otherwise this is a simple `merge --no-ff`
# https://gist.github.com/rocketraman/1fdc93feb30aa00f6f3a9d7d732102a9#file-gitconfig-L14
git mb $x || { onFail; break; }
done < /tmp/branches
if [[ "$failed" == "false" ]]; then onSuccess; fi
Usage:
bash rebuildto.sh {target_integration_branch} {from_integration_branch} {ancestor, default: master}
- all
pu
graduates tonext
bash rebuildto.sh next pu
orbash rebuildto.sh next pu master
- all
next
graduates tomaster
bash rebuildto.sh master next
orbash rebuildto.sh master next master