我有一个bash脚本,其中运行以下cherry-pick命令:
if git cherry-pick -x "$commitId"; then
ammed_commit "$BRANCH"
else
#here I want to check if this resulted in empty commit
fi
我尝试再次运行命令并将输出保存到字符串中,然后进行比较,但输出结果与控制台中所见不同。我正在使用以下脚本进行测试:
#!/bin/bash
READ_STATUS=$(git cherry-pick -x 001e6beda)
SUB_STRING="The previous cherry-pick is now empty"
echo $READ_STATUS
stringContain() { [ -z "${2##*$1*}" ]; }
if stringContain "$READ_STATUS" 'The previous cherry-pick is now empty';then
echo yes
else
echo no
fi
exit
以下是我运行这个脚本时收到的输出结果:
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git reset'
//READ_STATUS gets this value and not the one above this line???
On branch test-stage Your branch is ahead of 'upstream/test-stage' by 1 commit. (use "git push" to publish your local commits) You are currently cherry-picking commit 001e6beda. nothing to commit, working tree clean
no
我有两个问题:
- 为什么我的字符串没有完整的输出?
- 如何解决这个问题并成功地检查cherry-pick是否导致空提交?