-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add support for querying the events-log plugin #10
Conversation
@andygrunwald PTAL. It was not clear to me if there was anything for or against providing a function to parse the output of an optional plugin so I thought I'd open up a PR to discuss it. Even without Also, how do you think this should be tested? Most of the tests today talk to an external server which for this code won't work since it requires auth. Have you thought about having the tests spin up an http server that can provide responses to requests? |
Thank you @opalmer. I don`t have a problem with adding support for plugins. The plugins needs to "kind of" popular, but as far as i can see / know this applies to event-log. Related to testing: And it would be cool if you can add a note into the README (e.g. Features section) that we have support for this plugin as well. |
That's the one.
Awesome, thanks! I'm happy to add some notes to the README alone those lines if you think that would be appropriate for future contributors.
Sure happy to though it may be a bit before I can get it done (have some other things I'm working on at the moment).
Will do. |
@andygrunwald PTAL. Added tests, updated the README and fixed a couple of bugs. On a side note, I'll probably be opening another PR shortly to update the imports in the tests from EDIT Using |
Thank you. I merged all changes. Related to the tests: |
The current name of the test package is gerrit_test though and I was On Aug 2, 2016 2:31 AM, "Andy Grunwald" notifications@github.com wrote:
|
@opalmer I don't like the change with the import path. I understand your problem related to the fork. Would it be an option for you to |
@andygrunwald sorry for the delay, I've been traveling. Totally understand wanting to keep the import path as is so no argument there. Options B would be nice if you're ok with it 😄 . I'll still open PRs of course but having write access would help with development. Another added benefit is if you're ever away I can sub in for bug fixes and code reviews. On a related side note, it's probably a good idea if I try out option A anyway and add it to the README once I'm done. The setup is not all that complicated but a little documentation around the procedure, and why it's necessary, could help a future contributor. |
No worry. Looking forward to your changes. |
if index > -1 { | ||
// +1 to catch the \n as well | ||
body = body[(index + 1):] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code can be significantly simplified without changing behavior.
If body has ")]}'\n"
prefix, there's no need to use bytes.IndexByte
to find the first '\n'
character, it's known to be at index 4 because bytes.HasPrefix(body, []byte(")]}'\n"))
was true.
Also, since this is called often, it's probably a good idea to factor out []byte(")]}'\n")
into a single package scope variable, instead of potentially allocating once per RemoveMagicPrefixLine
call.
func RemoveMagicPrefixLine(body []byte) []byte {
if bytes.HasPrefix(body, magicPrefix) {
return body[5:]
}
return body
}
var magicPrefix = []byte(")]}'\n")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shurcooL, no issues here if you want to go ahead and make the changes. I'd do it myself but I don't currently have my local host setup to make the change and test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my bad sorry about that. Reviewed, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds support for querying information about Gerrit events via the optional events-log plugin. The structures this PR adds could also be used when parsing output from the built-in
gerrit stream-events
command over ssh.