Created
December 18, 2016 08:45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm -fr .git-rewrite | |
git fetch --all | |
git fetch --tags | |
git checkout master | |
git reset --hard origin/master | |
# | |
# git filter-branch -f --tree-filter ' | |
# echo "\n-- Working on $GIT_COMMIT"; | |
# export tag=$(git describe --tags --abbrev=0 $GIT_COMMIT); | |
# tag_major=$(echo $tag | cut -f1 -d.); | |
# tag_minor=$(echo $tag | cut -f2 -d.); | |
# tag_patch=$(echo $tag | cut -f3 -d.); | |
# echo -n " -- Current tag : $tag_major.$tag_minor.$tag_patch\n"; | |
# echo -n " -- Current CMakeLists.txt : "; grep "^set(CPACK_PACKAGE_VERSION_" CMakeLists.txt; | |
# echo -n " -- Current log : "; git log --oneline -n1 $GIT_COMMIT; | |
# sed -i "s/set(CPACK_PACKAGE_VERSION_MAJOR .*)/set(CPACK_PACKAGE_VERSION_MAJOR $tag_major)/" CMakeLists.txt; | |
# sed -i "s/set(CPACK_PACKAGE_VERSION_MINOR .*)/set(CPACK_PACKAGE_VERSION_MINOR $tag_minor)/" CMakeLists.txt; | |
# sed -i "s/set(CPACK_PACKAGE_VERSION_PATCH .*)/set(CPACK_PACKAGE_VERSION_PATCH $tag_patch)/" CMakeLists.txt; | |
# git diff; | |
# (git add CMakeLists.txt && git commit --amend) || echo " -- nothing to add"; | |
# #(git describe --tags --exact-match $GIT_COMMIT && git tag -f $tag) || echo "" | |
# ' 315.8.0..HEAD | |
rm /tmp/git-update-tag.sh | |
git filter-branch -f --tree-filter ' | |
echo "\n-- Working on $GIT_COMMIT"; | |
# gut current tag | |
export tag=$(git describe --tags --abbrev=0 $GIT_COMMIT); | |
tag_major=$(echo $tag | cut -f1 -d.); | |
tag_minor=$(echo $tag | cut -f2 -d.); | |
tag_patch=$(echo $tag | cut -f3 -d.); | |
echo " -- Current tag : $tag_major.$tag_minor.$tag_patch"; | |
echo " -- Current log : $(git log --oneline -n1 $GIT_COMMIT)"; | |
# fix tag number | |
sed -i "s/set(CPACK_PACKAGE_VERSION_MAJOR .*)/set(CPACK_PACKAGE_VERSION_MAJOR $tag_major)/" CMakeLists.txt; | |
sed -i "s/set(CPACK_PACKAGE_VERSION_MINOR .*)/set(CPACK_PACKAGE_VERSION_MINOR $tag_minor)/" CMakeLists.txt; | |
sed -i "s/set(CPACK_PACKAGE_VERSION_PATCH .*)/set(CPACK_PACKAGE_VERSION_PATCH $tag_patch)/" CMakeLists.txt; | |
# if current commit is exactly when we added tag version | |
(git describe --tags --exact-match $GIT_COMMIT > /dev/null 2>&1 && (echo " -- new tag $tag"; | |
echo " -- Updated tag $tag @ $GIT_COMMIT"; | |
echo "git tag -f $tag \$(git log --oneline | grep \"$(git log --oneline -n1 $GIT_COMMIT | cut -f2- -d\ )\" | cut -f1 -d\ )" >> /tmp/git-update-tag.sh | |
)) || echo "" | |
' 315.7.0..HEAD | |
bash /tmp/git-update-tag.sh | |
git --no-pager log --oneline --color --decorate=full 315.7.0..HEAD | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment