forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow pipes to be present in git username (argoproj#20040)
* fix: [argoproj#15949] split git revision metadata by newline not pipe symbol pipe symbol '|' could appear in username or commit message body Signed-off-by: Petr Studeny <[email protected]> * test: add test Signed-off-by: Blake Pettersson <[email protected]> * Update util/git/client_test.go Co-authored-by: Petr Studeny <[email protected]> Signed-off-by: Blake Pettersson <[email protected]> * test: fix test Signed-off-by: Blake Pettersson <[email protected]> --------- Signed-off-by: Petr Studeny <[email protected]> Signed-off-by: Blake Pettersson <[email protected]> Co-authored-by: Petr Studeny <[email protected]>
- Loading branch information
1 parent
a288b4d
commit 6002c7d
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"path" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
@@ -438,3 +439,43 @@ func Test_IsRevisionPresent(t *testing.T) { | |
revisionPresent = client.IsRevisionPresent("invalid-revision") | ||
assert.False(t, revisionPresent) | ||
} | ||
|
||
func Test_nativeGitClient_RevisionMetadata(t *testing.T) { | ||
tempDir := t.TempDir() | ||
client, err := NewClient(fmt.Sprintf("file://%s", tempDir), NopCreds{}, true, false, "", "") | ||
require.NoError(t, err) | ||
|
||
err = client.Init() | ||
require.NoError(t, err) | ||
|
||
p := path.Join(client.Root(), "README") | ||
f, err := os.Create(p) | ||
require.NoError(t, err) | ||
_, err = f.WriteString("Hello.") | ||
require.NoError(t, err) | ||
err = f.Close() | ||
require.NoError(t, err) | ||
|
||
err = runCmd(client.Root(), "git", "config", "user.name", "FooBar ||| something\nelse") | ||
require.NoError(t, err) | ||
err = runCmd(client.Root(), "git", "config", "user.email", "[email protected]") | ||
require.NoError(t, err) | ||
|
||
err = runCmd(client.Root(), "git", "add", "README") | ||
require.NoError(t, err) | ||
err = runCmd(client.Root(), "git", "commit", "--date=\"Sat Jun 5 20:00:00 2021 +0000 UTC\"", "-m", `| Initial commit | | ||
(╯°□°)╯︵ ┻━┻ | ||
`, "-a") | ||
require.NoError(t, err) | ||
|
||
metadata, err := client.RevisionMetadata("HEAD") | ||
require.NoError(t, err) | ||
require.Equal(t, &RevisionMetadata{ | ||
Author: `FooBar ||| somethingelse <[email protected]>`, | ||
Date: time.Date(2021, time.June, 5, 20, 0, 0, 0, time.UTC).Local(), | ||
Tags: []string{}, | ||
Message: "| Initial commit |\n\n(╯°□°)╯︵ ┻━┻", | ||
}, metadata) | ||
} |