Title: Project.repository_merge_base([...]) with forks (remotes) · python-gitlab/python-gitlab · Discussion #2883 · GitHub
Open Graph Title: Project.repository_merge_base([...]) with forks (remotes) · python-gitlab/python-gitlab · Discussion #2883
X Title: Project.repository_merge_base([...]) with forks (remotes) · python-gitlab/python-gitlab · Discussion #2883
Description: Project.repository_merge_base([...]) with forks (remotes)
Open Graph Description: I am trying to streamline some cherry-picking for gitlab workflows. The principle is simple: Create a merge-request and label it with a specific label that marks it to be backported (cherry picked)...
X Description: I am trying to streamline some cherry-picking for gitlab workflows. The principle is simple: Create a merge-request and label it with a specific label that marks it to be backported (cherry picked)...
Opengraph URL: https://github.com/python-gitlab/python-gitlab/discussions/2883
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Project.repository_merge_base([...]) with forks (remotes)","text":"I am trying to streamline some cherry-picking for gitlab workflows.
\nThe principle is simple:
\n\n- Create a merge-request and label it with a specific label that marks it to be backported (cherry picked)
\n- Run a script that can create the necassary cherry-pick command
\n
\nNow, I can rather simple get to the point where I have the source branch and target branch as objects in the API workflow:
\n# def get_project(project_id) -> Project\nmr = project.mergerequests.get(id)\nproject = get_project(project_id)\nsource = get_project(mr.source_project_id, mr.manager.gitlab).branches.get(mr.source_branch)\ntarget = project.branches.get(mr.target_branch)
\nGenerally these two originates from different sources, i.e. target.web_url != source.web_url.
\nI tried:
\nmb = project.repository_merge_base([\n target.commit[\"web_url\"],\n source.commit[\"web_url\"]\n])
\nto no avail (not that i fully expected this to work)...
\nSo basically, how can I use gitlab to extract the merge-base between the two branches? Or, can I retrieve the commits that will be added (or has been added) to target so I can create the necessary cherry-picks?
\nThe merge-request can either be merged, or not merged, both cases are interesting!
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"First thing I would do is look at the upstream documentation:
\nhttps://docs.gitlab.com/ee/api/repositories.html#merge-base
\nFrom my quick glance I don't think it will work how you hope. I believe it only takes refs aka SHA values.
\nOne thing that might be helpful for debugging is:
\ntarget.pprint() that should print out all the values in the object. Which can be helpful. All the Python GitLab objects support pprint(), pformat(), to_json(), and asdict(). Depending on the situation they can be useful in debugging code.
","upvoteCount":1,"url":"https://github.com/python-gitlab/python-gitlab/discussions/2883#discussioncomment-9549328"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:afbcd40a-3d2f-00ae-b7e2-0233d5d0d60a |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | E946:1EF577:127406:198E42:697272E7 |
| html-safe-nonce | f14445346bd159e8e1cfdc2163444d899256c8ce5491424e4fc65876d4df39f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTQ2OjFFRjU3NzoxMjc0MDY6MTk4RTQyOjY5NzI3MkU3IiwidmlzaXRvcl9pZCI6IjY4NzE5NjQ0NjQzOTYyNjgyNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c5ceeb1e4bb4d33b11f122e008aba79afd76e584b1afe7029813b37bed2172ba |
| hovercard-subject-tag | discussion:6723481 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-gitlab/python-gitlab/2883/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/4c4b765df5c28e32f3bf13b4266e84f0d67e7872246b47b5f1129fe4603ecf1d/python-gitlab/python-gitlab/discussions/2883 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c4b765df5c28e32f3bf13b4266e84f0d67e7872246b47b5f1129fe4603ecf1d/python-gitlab/python-gitlab/discussions/2883 |
| og:image:alt | I am trying to streamline some cherry-picking for gitlab workflows. The principle is simple: Create a merge-request and label it with a specific label that marks it to be backported (cherry picked)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3be355d8ea7ca74c4edec03a70ecaa8211862649e90886d88a4db13e6778e4c3 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-gitlab/python-gitlab git https://github.com/python-gitlab/python-gitlab.git |
| octolytics-dimension-user_id | 28886265 |
| octolytics-dimension-user_login | python-gitlab |
| octolytics-dimension-repository_id | 8077625 |
| octolytics-dimension-repository_nwo | python-gitlab/python-gitlab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8077625 |
| octolytics-dimension-repository_network_root_nwo | python-gitlab/python-gitlab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ae5b6c1e16519c3e3ad37a388f7cca2192a79a8 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width