我正在寻找一种方法来自动更新项目的主分支(已发布版本)的过程.
基本上只有两个分支将存在于原始存储库(开发和主控......当修补程序或特定的开发分支出现时可能更多).
但是,运行nvie文章中的所有命令(http://nvie.com/posts/a-successful-git-branching-model/)在向多个潜在维护者进行培训时容易出错.
为了缓解版本命名约定中可能的拼写错误问题,并使所有维护者的过程保持一致和可靠,我想编写一个脚本来验证输入.
这是我bump.sh调用的脚本,我给它一个新版本来更新.它负责其余过程的大部分工作.
me@server:~/git_repos/# ./bump.sh git_project
Enter new version (Current 1.0.5): 1.0.6
Are you sure you want to release version 1.0.6? (y|n): y
Switched to a new branch 'release-1.0.6'
Switched to branch 'master'
Deleted branch release-1.0.6 (was 4abcd98e).
If you need to undo this last commit, abort now and run:
git reset --hard HEAD~1
git tag -d 1.0.6
Do you want to push this to the origin server (THIS IS NOT EASILY UNDONE)? (y|n): y
Password for 'https://user@bitbucket.org':
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 704 bytes, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: bb/acl: user is allowed. accepted payload.
To https://remote_repository.../.git
ffffffab..010101ab master -> master
Finished merging.
Run Code Online (Sandbox Code Playgroud)
bump.sh
if [ ! -d "$1" ]; then
echo "Must pass git directory as the first argument."
exit 2;
fi
cd $1
echo -e "Enter new version (Current `git describe --abbrev=0 --tags`): \c "
while read ver; do
if ([[ ! -z "$ver" ]]) && ([ "$ver" == "`echo $ver | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$"`" ])
then
break
else
echo " Version entered ($ver) was not formatted properly."
echo -e "Enter new version (Current `git describe --abbrev=0 --tags`): \c "
fi
done
echo -e "Are you sure you want to release version $ver? (y|n): \c "
read confirm
if([ $confirm == "y" ]) then
git checkout -b release-$ver develop
git checkout master
result=`git merge --no-ff release-$ver`
if([ "$result" == "`echo $result | grep "^Already up-to-date\."`" ]) then
git branch -D release-$ver
echo "The branch is already up to date. Aborting version bump.";
exit 3;
else
git tag -a $ver -m "Used bump script."
git branch -D release-$ver
echo ""
echo "If you need to undo this last commit, abort now and run:"
echo " git reset --hard HEAD~1"
echo " git tag -d $ver"
echo ""
echo -e "Push this change to the origin server and merge back into the develop branch? (y|n): \c "
read confirm
if([ $confirm == "y" ]) then
git push origin master
git checkout develop
git merge master
fi
echo "Finished merging."
exit 1;
fi
else
echo "Aborted the version bump."
exit 1;
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2585 次 |
| 最近记录: |