Skip to content
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

Allow passing a Reference to Repository.merge() #1348

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

jorio
Copy link
Contributor

@jorio jorio commented Feb 7, 2025

This PR allows passing more types to Repository.merge. Previously, you could only pass a commit ID as an Oid or an str.

In addition to these two, you can now also pass a real Commit, or a Reference.

Passing in a Reference will enrich the merge with additional information. For example, Repository.message will specify the name of the branch being merged, instead of just stating a commit ID:

branch = repo.branches.local['other']
repo.merge(branch)
print(repo.message)  # "Merging branch 'other'"

If this PR is accepted, I believe passing an str should now be deprecated. The str is supposed to represent a commit ID, but users might intuit that the function also accepts ref names as an str, when in fact they should pass a real Reference object.

@jorio jorio changed the title Repository.merge: Allow annotating a commit from a Reference Allow passing a Reference to Repository.merge() Feb 7, 2025
@jdavid jdavid merged commit f0f1e97 into libgit2:master Feb 8, 2025
8 checks passed
@jdavid
Copy link
Member

jdavid commented Feb 8, 2025

If this PR is accepted, I believe passing an str should now be deprecated. The str is supposed to represent a commit ID, but users might intuit that the function also accepts ref names as an str, when in fact they should pass a real Reference object.

Agree, there should be a deprecation warning, could you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants