-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Include encoding in signature payload (#30174) #30181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -125,6 +125,73 @@ empty commit`, commitFromReader.Signature.Payload) | |
assert.EqualValues(t, commitFromReader, commitFromReader2) | ||
} | ||
|
||
func TestCommitWithEncodingFromReader(t *testing.T) { | ||
commitString := `feaf4ba6bc635fec442f46ddd4512416ec43c2c2 commit 1074 | ||
tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5 | ||
parent 47b24e7ab977ed31c5a39989d570847d6d0052af | ||
author KN4CK3R <[email protected]> 1711702962 +0100 | ||
committer KN4CK3R <[email protected]> 1711702962 +0100 | ||
encoding ISO-8859-1 | ||
gpgsig -----BEGIN PGP SIGNATURE----- | ||
|
||
iQGzBAABCgAdFiEE9HRrbqvYxPT8PXbefPSEkrowAa8FAmYGg7IACgkQfPSEkrow | ||
Aa9olwv+P0HhtCM6CRvlUmPaqswRsDPNR4i66xyXGiSxdI9V5oJL7HLiQIM7KrFR | ||
gizKa2COiGtugv8fE+TKqXKaJx6uJUJEjaBd8E9Af9PrAzjWj+A84lU6/PgPS8hq | ||
zOfZraLOEWRH4tZcS+u2yFLu3ez2Wqh1xW5LNy7xqEedMXEFD1HwSJ0+pjacNkzr | ||
frp6Asyt7xRI6YmgFJZJoRsS3Ktr6rtKeRL2IErSQQyorOqj6gKrglhrhfG/114j | ||
FKB1v4or0WZ1DE8iP2SJZ3n+/K1IuWAINh7MVdb7PndfBPEa+IL+ucNk5uzEE8Jd | ||
G8smGxXUeFEt2cP1dj2W8EgAxuA9sTnH9dqI5aRqy5ifDjuya7Emm8sdOUvtGdmn | ||
SONRzusmu5n3DgV956REL7x62h7JuqmBz/12HZkr0z0zgXkcZ04q08pSJATX5N1F | ||
yN+tWxTsWg+zhDk96d5Esdo9JMjcFvPv0eioo30GAERaz1hoD7zCMT4jgUFTQwgz | ||
jw4YcO5u | ||
=r3UU | ||
-----END PGP SIGNATURE----- | ||
|
||
ISO-8859-1` | ||
|
||
sha := &SHA1{0xfe, 0xaf, 0x4b, 0xa6, 0xbc, 0x63, 0x5f, 0xec, 0x44, 0x2f, 0x46, 0xdd, 0xd4, 0x51, 0x24, 0x16, 0xec, 0x43, 0xc2, 0xc2} | ||
gitRepo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo1_bare")) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, gitRepo) | ||
defer gitRepo.Close() | ||
|
||
commitFromReader, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) | ||
assert.NoError(t, err) | ||
if !assert.NotNil(t, commitFromReader) { | ||
return | ||
} | ||
assert.EqualValues(t, sha, commitFromReader.ID) | ||
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE----- | ||
|
||
iQGzBAABCgAdFiEE9HRrbqvYxPT8PXbefPSEkrowAa8FAmYGg7IACgkQfPSEkrow | ||
Aa9olwv+P0HhtCM6CRvlUmPaqswRsDPNR4i66xyXGiSxdI9V5oJL7HLiQIM7KrFR | ||
gizKa2COiGtugv8fE+TKqXKaJx6uJUJEjaBd8E9Af9PrAzjWj+A84lU6/PgPS8hq | ||
zOfZraLOEWRH4tZcS+u2yFLu3ez2Wqh1xW5LNy7xqEedMXEFD1HwSJ0+pjacNkzr | ||
frp6Asyt7xRI6YmgFJZJoRsS3Ktr6rtKeRL2IErSQQyorOqj6gKrglhrhfG/114j | ||
FKB1v4or0WZ1DE8iP2SJZ3n+/K1IuWAINh7MVdb7PndfBPEa+IL+ucNk5uzEE8Jd | ||
G8smGxXUeFEt2cP1dj2W8EgAxuA9sTnH9dqI5aRqy5ifDjuya7Emm8sdOUvtGdmn | ||
SONRzusmu5n3DgV956REL7x62h7JuqmBz/12HZkr0z0zgXkcZ04q08pSJATX5N1F | ||
yN+tWxTsWg+zhDk96d5Esdo9JMjcFvPv0eioo30GAERaz1hoD7zCMT4jgUFTQwgz | ||
jw4YcO5u | ||
=r3UU | ||
-----END PGP SIGNATURE----- | ||
`, commitFromReader.Signature.Signature) | ||
assert.EqualValues(t, `tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5 | ||
parent 47b24e7ab977ed31c5a39989d570847d6d0052af | ||
author KN4CK3R <[email protected]> 1711702962 +0100 | ||
committer KN4CK3R <[email protected]> 1711702962 +0100 | ||
encoding ISO-8859-1 | ||
|
||
ISO-8859-1`, commitFromReader.Signature.Payload) | ||
assert.EqualValues(t, "KN4CK3R <[email protected]>", commitFromReader.Author.String()) | ||
|
||
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) | ||
assert.NoError(t, err) | ||
commitFromReader.CommitMessage += "\n\n" | ||
commitFromReader.Signature.Payload += "\n\n" | ||
assert.EqualValues(t, commitFromReader, commitFromReader2) | ||
} | ||
|
||
func TestHasPreviousCommit(t *testing.T) { | ||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.