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 no empty input check in newSignatureFromCommitline for gogit version #28849

Closed
wants to merge 5 commits into from

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Jan 19, 2024

Fix #28840

In signature_nogogit,go:
image

In signature_gogit.go:
image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 19, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 19, 2024
@lunny
Copy link
Member

lunny commented Jan 19, 2024

Can you add some tests?

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 22, 2024
@yp05327
Copy link
Contributor Author

yp05327 commented Jan 22, 2024

How to add test in both nogit and gogit version? 🤔

@lunny lunny added the backport/v1.21 This PR should be backported to Gitea 1.21 label Jan 22, 2024
@lunny lunny added this to the 1.22.0 milestone Jan 22, 2024
@lunny
Copy link
Member

lunny commented Jan 22, 2024

Have you tested Linux kernal?

@lunny
Copy link
Member

lunny commented Jan 22, 2024

How to add test in both nogit and gogit version? 🤔

It seems you have to change them twice at the moment.

@yp05327
Copy link
Contributor Author

yp05327 commented Jan 23, 2024

Have you tested Linux kernal?

Yes. It works well.

@yp05327
Copy link
Contributor Author

yp05327 commented Jan 24, 2024

It seems you have to change them twice at the moment.

A copy from signature_gogit_test.go is allowed? But seems no better method.

@lunny
Copy link
Member

lunny commented Jan 24, 2024

It seems you have to change them twice at the moment.

A copy from signature_gogit_test.go is allowed? But seems no better method.

You can copy first and then try to extract a function

@yp05327
Copy link
Contributor Author

yp05327 commented Jan 29, 2024

I understanded now.
Just remove //go:build gogit in the test.go, then we can test it in both gogit version and no gogit version. 😄

image

@@ -21,38 +21,59 @@ type Signature = object.Signature
// Helper to get a signature from the commit line, which looks like these:
//
// author Patrick Gundlach <gundlach@speedata.de> 1378823654 +0200
// author Patrick Gundlach <gundlach@speedata.de> Thu, 07 Apr 2005 22:13:13 +0200
// author Patrick Gundlach <gundlach@speedata.de> Thu Apr 07 22:13:13 2005 +0200
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the code is different from nogogit? And it seems that the nogogit function does pretty well on parsing the date/time:

image

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 5, 2024

@yp05327 after reading the code again, I think we should rewrite the code (for both gogit and nogogit). If you don't mind, I could propose a new approach soon.

@yp05327
Copy link
Contributor Author

yp05327 commented Feb 5, 2024

@yp05327 after reading the code again, I think we should rewrite the code (for both gogit and nogogit). If you don't mind, I could propose a new approach soon.

Never mind. It seems that the old codes haven’t been finished yet. So let’s finish it.

@yp05327 yp05327 closed this Feb 5, 2024
@GiteaBot GiteaBot removed this from the 1.22.0 milestone Feb 5, 2024
@wxiaoguang
Copy link
Contributor

-> Refactor parseSignatureFromCommitLine #29054

wxiaoguang added a commit that referenced this pull request Feb 9, 2024
Replace #28849. Thanks to @yp05327 for the looking into the problem.
Fix #28840

The old behavior of newSignatureFromCommitline is not right. The new
parseSignatureFromCommitLine:

1. never fails
2. only accept one format (if there is any other, it could be easily added)

And add some tests.
wxiaoguang added a commit to wxiaoguang/gitea that referenced this pull request Feb 9, 2024
Replace go-gitea#28849. Thanks to @yp05327 for the looking into the problem.
Fix go-gitea#28840

The old behavior of newSignatureFromCommitline is not right. The new
parseSignatureFromCommitLine:

1. never fails
2. only accept one format (if there is any other, it could be easily added)

And add some tests.
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 20, 2024
Replace go-gitea#28849. Thanks to @yp05327 for the looking into the problem.
Fix go-gitea#28840

The old behavior of newSignatureFromCommitline is not right. The new
parseSignatureFromCommitLine:

1. never fails
2. only accept one format (if there is any other, it could be easily added)

And add some tests.
6543 pushed a commit to 6543-forks/gitea that referenced this pull request Feb 26, 2024
Replace go-gitea#28849. Thanks to @yp05327 for the looking into the problem.
Fix go-gitea#28840

The old behavior of newSignatureFromCommitline is not right. The new
parseSignatureFromCommitLine:

1. never fails
2. only accept one format (if there is any other, it could be easily added)

And add some tests.

(cherry picked from commit a24e1da)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
@lunny lunny removed the backport/v1.21 This PR should be backported to Gitea 1.21 label Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slice bounds out of range in function: /modules/git.newSignatureFromCommitline
4 participants