mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
fix: use unique names for initial commits (#27171)
Signed-off-by: Sean Liao <sean@liao.dev>
This commit is contained in:
parent
f298f4500f
commit
45a32a5c32
2 changed files with 6 additions and 1 deletions
|
|
@ -1045,7 +1045,7 @@ func (m *nativeGitClient) CheckoutOrOrphan(branch string, submoduleEnabled bool)
|
|||
}
|
||||
|
||||
// Make an empty initial commit.
|
||||
out, err = m.runCmd(ctx, "commit", "--allow-empty", "-m", "Initial commit")
|
||||
out, err = m.runCmd(ctx, "commit", "--allow-empty", "-m", "Initial commit for "+branch)
|
||||
if err != nil {
|
||||
return out, fmt.Errorf("failed to commit initial commit: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,6 +697,11 @@ func Test_nativeGitClient_CheckoutOrOrphan(t *testing.T) {
|
|||
currentCommitHash := strings.TrimSpace(string(gitCurrentCommitHash))
|
||||
require.NotEqual(t, baseCommitHash, currentCommitHash)
|
||||
|
||||
gitCurrentCommitMessage, err := outputCmd(ctx, tempDir, "git", "log", "--format=%B", "-n", "1", "HEAD")
|
||||
require.NoError(t, err)
|
||||
currentCommitMessage := strings.TrimSpace(string(gitCurrentCommitMessage))
|
||||
require.Contains(t, currentCommitMessage, expectedBranch)
|
||||
|
||||
// get commit count on current branch, verify 1 -> orphan
|
||||
gitCommitCount, err := outputCmd(ctx, tempDir, "git", "rev-list", "--count", actualBranch)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue