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
x/build/maintner: reports incorrect Hashtags for some CLs #28318
Comments
This would be a good issue for anyone who wants to help out and do some investigation. It'd be very helpful for us to find out what's causing this, or what the pattern of affected CLs is. |
Change https://golang.org/cl/145258 mentions this issue: |
This change expands the scope of cmd/maintserve to visualize Gerrit CL maintner data, in addition to the GitHub repository issue tracker data. I've needed this recently when investigating golang/go#28318 to check maintner.GerritHashtags values of various CLs. They are shown as of https://dmitri.shuralyov.com/service/change/...$commit/e712a6949fbe7fe04b2f49fc22810f827b17f3f8. maintner doesn't have sufficient information to present Gerrit CLs in full detail, so this does a best effort and displays the available information. Inline review comments and diffs are not included. The downside of this change is that it adds new dependencies. However, they are actively maintained by me. Updates golang/go#28318 Change-Id: Ie6fe14f95f107e95371ea820af88563e03a6bb2a Reviewed-on: https://go-review.googlesource.com/c/145258 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@dmitshur Hi! :) I'm a first time contributor here. I have experience with Go and would very much like to investigate, go down a rabbit hole and find out what's happening and fix it. :) I've read the surrounding issues and have a vague idea of where to start. I have very little knowledge yet, but I seek to understand things better and be a contributor to Go in the long run. This is the first programming language I love to use for years and I would like to give back to it! If you don't mind, I would like to take a stab at this. I've read the contribution guideline and did setup my environment. |
@Skarlso, go for it. This is a nice self-contained problem so it'd be a good starter bug. Thanks! |
Awesomesauce! On it. :) Thanks! |
Okay, I had time a little to play with this. What's happening is, that this thing is parsing the commit message to access the last entry like this: // Footer returns the "key: value" lines at the base of the commit.
func (m *GerritMeta) Footer() string {
i := strings.LastIndex(m.Commit.Msg, "\n\n")
if i == -1 {
return ""
}
return m.Commit.Msg[i+2:]
} Looking for a thing called Hashtag in here. What's happening is, that on some issues, the commit message is updated, and the LAST entry in the list of commit messages will not be something that contains a Hashtag entry, but rather a message like, Which in turn will no longer have this entry:
To see this on issues look at this where the commit message is updated: https://go-review.googlesource.com/c/gddo/+/135536 And look at this issue where it's not and the hashtag is properly parsed out: https://go-review.googlesource.com/c/go/+/95895 I'm not sure yet what the fix will be, but I'm on the right path, I think. It's getting later however, so I'll be continuing this tomorrow. |
The fix will probably involve parsing out the hashtag from somewhere else maybe, or something like, if it's encountered, save it and always display it unless a remove is encountered. Not sure yet. Also, I need to fully understand what's happening in the display code under gerrit.go. :) |
I have a failing unit test! commit: `Update patch set 1
Hashtag added: bar
Patch-set: 1
Hashtags:
Tag: autogenerated:gerrit:setHashtag
Update patch set 2
`,
wantAdd: "bar",
}, The exact problem is that this line: Tag: autogenerated:gerrit:setHashtag ... is missing from the consecutive update. Which makes things more interesting. If this line would be sent along the update, things would work. |
To be accurate this is how it actually looks like: commit: `Update patch set 1
Hashtag added: bar
Patch-set: 1
Hashtags:
Tag: autogenerated:gerrit:setHashtag
Create patch set 5
Uploaded patch set 5: Commit message was updated.
Patch-set: 5
Subject: gddo-server: fix expanding examples containing reserved characters
Commit: 9ef378a957aa4313a34acfdcd3d0bcdca2e7b9d1
Tag: autogenerated:gerrit:newPatchSet
Groups: 9ef378a957aa4313a34acfdcd3d0bcdca2e7b9d1
`,
wantAdd: "bar",
}, |
I think I understand what's going on. The parser parses the messages backwards then reverses the commits messages so we get the last one. But the last one in this case will be a newPatchSet and will not contain the setHashtag action. So, I'm wondering. Is this something that you (@dmitshur) tried to address with your change set here: https://go-review.googlesource.com/c/build/+/145258/ ? |
Yeah no. That only seems to be an update on displaying things. Doesn't change anything relevant to this issue if I understand it correctly |
I have a working fix 🎉 Need to write some unit tests around it first and work out some quirks. |
for certain commits. Bug: The previous implementation was only looking at the last commit message in order to parse out the hashtags. However, the last commit message was not always a tag action. This function of displaying the correct hashtags was not at all aware of the state of hashtags. Fix: The current implementation looks at all commits regarding an issue and works like a state machine by parsing the parent commit messages as well as the current one. The states can be added, removed or no action at all. Once all messages are parsed the correct tags are joined together and returned correctly. Fixes golang/go#28318
hashtags on a Gerrit CL using a tag state machine. In order to see all hashtags properly when running maintner, a tag state machine was introduced to track changes made to them during the life cycle of a Gerrit issue. Now tags are visible on each issue in the correct format as present in Gerrit. Fixes golang/go#28318
Change https://golang.org/cl/150075 mentions this issue: |
Change https://golang.org/cl/152779 mentions this issue: |
Change https://golang.org/cl/153441 mentions this issue: |
Change https://golang.org/cl/153442 mentions this issue: |
In CL 152779, lineValue was modified to return just the value, lineValueRest was added to do the same task as the old lineValue, and a new lineValueOK with a third bool return value was created. This change fixes a test build failure by adapting TestLineValue to use the new lineValueOK function, and renaming it to TestLineValueOK. Also add two test cases to cover the new bool return value. Updates golang/go#28318 Change-Id: I08106cc14f0c418a880ab139310830943a3a1ad9 Reviewed-on: https://go-review.googlesource.com/c/153441 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TestGerritHashtags is documented to be off by default unless environment variable TEST_GERRIT_AUTH is set to "user:token", or we're running in the prod project. However, the previous code never skipped TestGerritHashtags, even when TEST_GERRIT_AUTH wasn't set, because strings.SplitN returns a slice with length 1 when the input string is empty. This change fixes that. Updates golang/go#28318 Change-Id: Ib2f113dbc3ccfd933f9944fe8efa105ff3ba5057 Reviewed-on: https://go-review.googlesource.com/c/153442 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
CL https://go-review.googlesource.com/c/gddo/+/135536 (36 days old) has a
no-owners
hashtag:However, the current
maintner
corpus reports that it does not have any hashtags:It should print
true
.This also affects some other CLs, including (not an exhaustive list):
So far, I haven't found the pattern of which CLs are affected. It seems to affect CLs in main repo and subrepo, and affects quite recent CLs as well as older ones. Many other CLs have correct hashtags.
/cc @bradfitz
The text was updated successfully, but these errors were encountered: