-
Notifications
You must be signed in to change notification settings - Fork 115
Support merged pull requests for github and gitlab
#311
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the pull request. Actually, the Not sure how exactly the query |
|
I'll say that I don't understand the logic behind "closed". When I use |
|
PR can be closed because of being merged or declined. This takes just the successful PRs. |
Pull requests authored by a user are covered by
Understood. It might make sense to separate closed (without merge) and merged pull requests. However, we need to make sure the stat is working as expected. As mentioned in the comment above, some of the pull requests merged by me in the given time frame are not reported by the new stat. Could you please, have a look into that? |
|
Hi @psss!
I think of the assignee as the reviewer*. I dig the idea of
Having worked on CLIs for more than 20y, I appreciate that you may not want to maintain a massive proliferation of flags. That said, I could envision the following non-mutually-exclusive options that could be used in conjunction with all/most of the
...where the default is I haven't thought through whether/how these could also apply to *I imagine different shops use different processes, so this may not apply universally, but this is how it's done at Red Hat, at least in the OpenShift org, so I know it's not just me :) |
Well, for reviewers there's a dedicated field, right? I would not suggest to duplicate the meaning.
Just to clarify, the existing
+1 for having
Your suggested name |
Mm, fair point. The difference being that any schmo can leave a review, whereas in our process the assignee's reviews are the "important" ones -- specifically the ones that the author expects to move the PR toward getting merged. I guess the subtleties of different processes come into play here... but empirically having separate flags for "assigned" vs "reviewed" PRs would give users the flexibility to report in whatever way is most appropriate for them.
If I could further filter by open/abandoned/merged, I would think so, yes. |
This is straightforward. The The I need the merged PR (authored by me), as I report the code I, personally, contributed. |
Isn't the credit for authoring a pull request covered by |
The |
|
Thanks much for the clarification and sorry for the late response. So it's about getting the work until the finish (merging) and the date is clearly different. Makes sense now. Let's do it as you suggest. Could you please rebase on the latest |
merged pull requests for github and gitlab
|
Can you please rebase? |
857b9f6 to
2c698a5
Compare
Done. Sorry for being inactive on this! |
sandrobonazzola
left a comment
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.
The GitHub part looks good for merging. Some questions on the GitLab one.
Other questions:
- Should we filter by merge date or update date? The PR discussion suggests merge date, but the implementation seems to use update date.
- Should we add unit tests similar to the existing GitLab tests?
did/plugins/gitlab.py
Outdated
| 'author_username': username, | ||
| 'state': state, | ||
| 'updated_after': since, | ||
| 'updated_before': until |
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.
Is it intentional not setting get_all_results=True here?
Only the first page of results will be fetched here.
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.
Also, has the GitLab global merge_requests endpoint been tested with a real token? Does it work for all users or only admins?
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.
Thanks for catching this! I forgot about pagination. I've fixed this by adding get_all_results=True to the get_user_mr() method call.
The /api/v4/merge_requests endpoint is accessible to any authenticated user and respects their visibility permissions - users will only see MRs they have access to view.
Yes, I tested this on a real Gitlab instance. In fact, I've been using this branch for years now! 😆
did/plugins/gitlab.py
Outdated
| super().__init__(data, parent, set_id) | ||
|
|
||
| def _get_title(self): | ||
| return self.data['title'] |
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.
isn't self.data['target_title'] available for MergeRequests?
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.
IMHO, the MergedRequest class is necessary because of data structure differences between the global merge_requests API and the events API:
- Global API (used by
get_user_mr()): Returns MR objects directly with fields likeiidandtitle - Events API (used by other
MergeRequeststats): Returns event objects with nested fields liketarget_idandtarget_title
I've added detailed comments explaining this in the code. The MergedRequest class handles these differences by:
- Taking
iiddirectly from the data instead of making an extra API call - Using data['title'] instead of data['target_title']
Without this class, we'd need to modify the base Issue class to handle both data formats, which would complicate the code.
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.
Take a look at 8f5e5ee. I found, that the Markdown formatting requires some params in data, so I remapped the param, and so the _get_title() isn't needed anymore.
2c698a5 to
c048fbb
Compare
|
In its current form this should close #371 |
That's right. I'll update the code to use the merge date. Those two dates are often the same, but the MR might be updated after it's merged, so yes.
Yep, I'll add those... |
c048fbb to
dd7c2d5
Compare
|
The readthedocs #30370221 failure was likely due to yesterday's Github outage: https://www.githubstatus.com/incidents/5q7nmlxz30sk |
Filter by merged_at timestamp (not updated_at) and add tests for both GitLab and GitHub merge-requests-merged functionality.
Transform MR data structure to include target_title and target_type fields expected by parent Issue class, eliminating the need for method overrides.
8f5e5ee to
ae4b8d0
Compare
|
Maybe this was already asked. If I were to merge this very PR I suppose it will not show up in the list because I'm not the author, right? Is that what we want? I think there's value in both, PRs / MRs that were merged on your behalf or those that you've merged yourself. |
This PR is adding Usually in open-source you can't merge PRs yourself. And if you do, this PR is also the thing you want: the work you proposed, and then it was merged. You want to list the PRs you merged, even though you are not the author of them? If so, this PR doesn't do that. |
Changes