diff options
author | zeripath <art27@cantab.net> | 2021-05-12 06:11:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-12 01:11:42 -0400 |
commit | 2a565478d17f4a1b59a77b0e2251dd7b7de862c4 (patch) | |
tree | e300874a9199a9579767e0477d55a53c21d56d45 /modules | |
parent | 3d7d750a999b72d422000154a0b1f2801614521e (diff) | |
download | gitea-2a565478d17f4a1b59a77b0e2251dd7b7de862c4.tar.gz gitea-2a565478d17f4a1b59a77b0e2251dd7b7de862c4.zip |
Tagger can be empty, as can Commit and Author - tolerate this (#15835)
Unfortunately some old repositories can have tags with empty Tagger, Commit
or Author. Go-Git variants will always have empty values for these whereas
the native git variant leaves them at nil. The simplest solution is just to
always have these set to empty Signatures.
v156 migration also makes the incorrect assumption that these cannot be empty.
Therefore add some handling to this and add logging and adjust broken
logging elsewhere in this migration.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/commit_reader.go | 4 | ||||
-rw-r--r-- | modules/git/tag.go | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index a4d15b6bad..3c1f6f5ffd 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -17,7 +17,9 @@ import ( // If used as part of a cat-file --batch stream you need to limit the reader to the correct size func CommitFromReader(gitRepo *Repository, sha SHA1, reader io.Reader) (*Commit, error) { commit := &Commit{ - ID: sha, + ID: sha, + Author: &Signature{}, + Committer: &Signature{}, } payloadSB := new(strings.Builder) diff --git a/modules/git/tag.go b/modules/git/tag.go index 0323cc42ed..23f09e25b6 100644 --- a/modules/git/tag.go +++ b/modules/git/tag.go @@ -35,6 +35,7 @@ func (tag *Tag) Commit() (*Commit, error) { // \n\n separate headers from message func parseTagData(data []byte) (*Tag, error) { tag := new(Tag) + tag.Tagger = &Signature{} // we now have the contents of the commit object. Let's investigate... nextline := 0 l: |