Skip to content
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

Fix git.parseTagData #14105

Merged
merged 9 commits into from
Dec 22, 2020
Merged

Conversation

6543
Copy link
Member

@6543 6543 commented Dec 22, 2020

fix #14092

@6543 6543 added the type/bug label Dec 22, 2020
@6543 6543 added this to the 1.14.0 milestone Dec 22, 2020
modules/git/tag.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 22, 2020
modules/git/tag_test.go Outdated Show resolved Hide resolved
@6543
Copy link
Member Author

6543 commented Dec 22, 2020

@lunny thanks - good 👀!

EDIT: just saw the test error log too 🙃

@6543 6543 mentioned this pull request Dec 22, 2020
6 tasks
@zeripath
Copy link
Contributor

We need to do something slightly different here.

The issue is a that parseTagData is sometimes passed the terminal newline and sometimes not.

I think your code potentially is correct without the terminal newline but all of the rest of the calls need to be similarly limited.

Our unit tests should probably use []byte arrays too.

@6543
Copy link
Member Author

6543 commented Dec 22, 2020

@zeripath while test git migration from repo in reported issue ... out of 177 tags only 2 tags executed this function

So its not crear to me why this function exist ...

Is it some sort of workaround?

@zeripath

This comment has been minimized.

@zeripath
Copy link
Contributor

The function exists because most tags in that repo are not annotated tags. parseTagData only applies to annotated tags.

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

zeripath commented Dec 22, 2020

The TestAPIGitTags is also fundamentally incorrect because the message is always trimmed and terminated with a new line with -m

Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 22, 2020
modules/git/tag_test.go Outdated Show resolved Hide resolved
assert.EqualValues(t, test.tag.Signature.Payload, tag.Signature.Payload)
} else {
assert.Nil(t, tag.Signature)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the fixture data which defined above (testData) this: if test.tag.Signature != nil is from my understanding always nil ? That would mean that the given if ... else is not necessary... Or do I misunderstand a thing here?
If it should not nil in some cases then some testData is missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be simplified a bit yes

In sort, it's a custom assert.EqualValues(t, test.tag, tag) ... witch would be false in any case ... :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry took a bit of time that you control the checking of the result of parseTagData based on the content of the fixture (testData)... now it makes sense to me... just missed that point.

} else {
assert.Nil(t, tag.Tagger)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here from my point of view the same thing because test.tag.Tagger would always not nil ?... WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short it 1. Check if value is expected ... 2. check if actual value is not nil (with assert test statement)
if expect & real is NOT nil, it checks the values
else (test already failed if expect != real, or nil is exptected - so...) test if result is nil

@GiteaBot GiteaBot removed the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Dec 22, 2020
@GiteaBot GiteaBot added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Dec 22, 2020
@6543 6543 merged commit 27fa481 into go-gitea:master Dec 22, 2020
@6543 6543 deleted the fix-14092_git-parseTagData branch December 22, 2020 20:44
@go-gitea go-gitea locked and limited conversation to collaborators Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The API fails at displaying tags
5 participants