-
-
Notifications
You must be signed in to change notification settings - Fork 969
Add porcelain-style convenience APIs on Repo (create_branch and merge)
#2120
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -170,6 +170,12 @@ class Repo: | |||||
| """Subclasses may easily bring in their own custom types by placing a constructor or | ||||||
| type here.""" | ||||||
|
|
||||||
| def create_branch(self, *args: Any, **kwargs: Any) -> Head: | ||||||
| return self.create_head(*args, **kwargs) | ||||||
|
|
||||||
| def merge(self, *args: Any, **kwargs: Any) -> str: | ||||||
|
||||||
| def merge(self, *args: Any, **kwargs: Any) -> str: | |
| def merge(self, *args: Any, **kwargs: Any) -> Any: |
Copilot
AI
Mar 26, 2026
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 PR/issue description suggests an ergonomic call like repo.merge(from=branch_name), but this wrapper doesn't introduce any named parameter (and Python can't accept a keyword named from). If the intent is a porcelain-style API, consider adding an explicit named argument (e.g., from_/other/rev) and mapping it to the positional merge target, rather than only exposing the low-level *args/**kwargs passthrough.
Copilot
AI
Mar 26, 2026
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.
New public Repo convenience methods are added here (create_branch, merge), but there are no tests ensuring they behave as intended (e.g., create_branch being an alias of create_head, and merge delegating to git merge successfully). Given the existing test coverage around create_head/repo operations, adding a small test would help prevent regressions and clarify expected behavior (including error behavior on conflicts).
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.
create_branchis a new public API but currently just forwards*args/**kwargswith no docstring. That loses the explicit signature ofcreate_head(path/commit/force/logmsg), weakens type checking and makes the API harder to discover in docs/IDE autocomplete. Consider givingcreate_branchthe same explicit parameters and a short docstring that points tocreate_head/Head.create(and optionally place it next tocreate_headfor discoverability).