Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Project.repository_merge_base([...]) with forks (remotes)#2883

AnsweredbyJohnVillalovos
zerothi asked this question inQ&A
Discussion options

I am trying to streamline some cherry-picking for gitlab workflows.

The principle is simple:

  1. Create a merge-request and label it with a specific label that marks it to be backported (cherry picked)
  2. Run a script that can create the necassary cherry-pick command

Now, I can rather simple get to the point where I have the source branch and target branch as objects in the API workflow:

# def get_project(project_id) -> Projectmr=project.mergerequests.get(id)project=get_project(project_id)source=get_project(mr.source_project_id,mr.manager.gitlab).branches.get(mr.source_branch)target=project.branches.get(mr.target_branch)

Generally these two originates from different sources, i.e.target.web_url != source.web_url.

I tried:

mb=project.repository_merge_base([target.commit["web_url"],source.commit["web_url"]])

to no avail (not that i fully expected this to work)...

So basically, how can I usegitlab to extract the merge-base between the two branches? Or, can I retrieve the commits that will be added (or has been added) totarget so I can create the necessary cherry-picks?

The merge-request can either be merged, or not merged, both cases are interesting!

You must be logged in to vote

First thing I would do is look at the upstream documentation:

https://docs.gitlab.com/ee/api/repositories.html#merge-base

From my quick glance I don't think it will work how you hope. I believe it only takesrefs aka SHA values.

One thing that might be helpful for debugging is:
target.pprint() that should print out all the values in the object. Which can be helpful. All the Python GitLab objects supportpprint(),pformat(),to_json(), andasdict(). Depending on the situation they can be useful in debugging code.

Replies: 1 comment 1 reply

Comment options

First thing I would do is look at the upstream documentation:

https://docs.gitlab.com/ee/api/repositories.html#merge-base

From my quick glance I don't think it will work how you hope. I believe it only takesrefs aka SHA values.

One thing that might be helpful for debugging is:
target.pprint() that should print out all the values in the object. Which can be helpful. All the Python GitLab objects supportpprint(),pformat(),to_json(), andasdict(). Depending on the situation they can be useful in debugging code.

You must be logged in to vote
1 reply
@zerothi
Comment options

Thanks for your feedback, indeed it doesn't look like it.

As for the debugging, I already played withpprint with great satisfaction. ;)

Answer selected byzerothi
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@zerothi@JohnVillalovos

[8]ページ先頭

©2009-2025 Movatter.jp