如果以前的提交被重新纠正,管道将失败
当将提交合并到主人身上时,我能够运行管道以检查是否需要重新重新进行,但是一旦将提交重新构成并与主分支同步,它将通过管道。我的脚本是比较合并完成后的两个父母所做的。如果将提交重新列入并将其合并到Bitbucket Master分支,则搜索使管道失败的方法。
我的脚本如下:
#!/bin/bash
trg=$1
itg=$2
parent_commit_count=$(git cat-file -p $BITBUCKET_COMMIT | grep -o -i parent | wc -l)
echo "Number of parent commits:"$parent_commit_count
if [ "${parent_commit_count}" = "2" ]
then
echo "Validating master branch graph shape"
fi
if [[ -z $trg ]]; then
trg=HEAD
fi
if [[ -z $itg ]]; then
itg=master
fi
ret=$(git rev-list $trg..$itg)
if [[ -z $ret ]]; then
echo "No rebase required, sexy graph is maintained."
else
echo "Commit $BITBUCKET_COMMIT needs to be rebased to absorb the following changes:"
for r in $ret
do
echo $r
done
exit 1
fi
branches:
master:
- step:
name: Branch Trigger to Master
script:
- echo "Checking Merge Commit"
- chmod +x MergeCommitCheck.sh && ./MergeCommitCheck.sh
I was able to run a pipeline to check if rebased was required or not when a commit is merged onto master, but once the commit is rebased and synced with master branch, it passes the pipeline. My script is comparing the 2 parents commits when the merge is done. Searching for ways to make the pipeline fail if commit was rebased and merged onto bitbucket master branch.
My script is as follows:
#!/bin/bash
trg=$1
itg=$2
parent_commit_count=$(git cat-file -p $BITBUCKET_COMMIT | grep -o -i parent | wc -l)
echo "Number of parent commits:"$parent_commit_count
if [ "${parent_commit_count}" = "2" ]
then
echo "Validating master branch graph shape"
fi
if [[ -z $trg ]]; then
trg=HEAD
fi
if [[ -z $itg ]]; then
itg=master
fi
ret=$(git rev-list $trg..$itg)
if [[ -z $ret ]]; then
echo "No rebase required, sexy graph is maintained."
else
echo "Commit $BITBUCKET_COMMIT needs to be rebased to absorb the following changes:"
for r in $ret
do
echo $r
done
exit 1
fi
Pipeline:
branches:
master:
- step:
name: Branch Trigger to Master
script:
- echo "Checking Merge Commit"
- chmod +x MergeCommitCheck.sh && ./MergeCommitCheck.sh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论