Skip to content

cleanup: consolidate all repo operations into Repository methods#125

Merged
unknwon merged 10 commits intov2from
cleanup/remove-redundant-helpers
Feb 14, 2026
Merged

cleanup: consolidate all repo operations into Repository methods#125
unknwon merged 10 commits intov2from
cleanup/remove-redundant-helpers

Conversation

@unknwon
Copy link
Member

@unknwon unknwon commented Feb 14, 2026

Summary

This is a breaking change for v2 that consolidates the API by removing all redundant top-level functions that accept repoPath as the first parameter. These functions have been moved directly into Repository methods.

Problem

The previous API had a confusing mix of:

  1. Top-level functions: Push(repoPath, remote, branch)
  2. Repository methods: repo.Push(remote, branch)
  3. Deprecated wrappers: RepoPush(repoPath, remote, branch)

This tripled the API surface without adding value.

Solution

Removed 28 top-level functions - use Repository methods instead:

Removed Function Use Instead
Push(repoPath, ...) repo.Push(...)
Checkout(repoPath, ...) repo.Checkout(...)
Reset(repoPath, ...) repo.Reset(...)
Move(repoPath, ...) repo.Move(...)
Add(repoPath, ...) repo.Add(...)
CreateCommit(repoPath, ...) repo.Commit(...)
ShowNameStatus(repoPath, ...) repo.ShowNameStatus(...)
CountObjects(repoPath, ...) repo.CountObjects(...)
Fsck(repoPath, ...) repo.Fsck(...)
Log(repoPath, ...) repo.Log(...)
DiffNameOnly(repoPath, ...) repo.DiffNameOnly(...)
MergeBase(repoPath, ...) repo.MergeBase(...)
ShowRefVerify(repoPath, ...) repo.ShowRefVerify(...)
SymbolicRef(repoPath, ...) repo.SymbolicRef(...)
DeleteBranch(repoPath, ...) repo.DeleteBranch(...)
HasReference(repoPath, ...) repo.HasReference(...)
HasBranch(repoPath, ...) repo.HasBranch(...)
HasTag(repoPath, ...) repo.HasTag(...)
RemoteAdd(repoPath, ...) repo.RemoteAdd(...)
RemoteRemove(repoPath, ...) repo.RemoteRemove(...)
Remotes(repoPath, ...) repo.Remotes(...)
RemoteGetURL(repoPath, ...) repo.RemoteGetURL(...)
RemoteSetURL(repoPath, ...) repo.RemoteSetURL(...)
RemoteSetURLAdd(repoPath, ...) repo.RemoteSetURLAdd(...)
RemoteSetURLDelete(repoPath, ...) repo.RemoteSetURLDelete(...)
Tags(repoPath, ...) repo.Tags(...)

Kept top-level functions (no repo required):

  • Init(path, ...) - creates new repo
  • Clone(url, dst, ...) - clones repo
  • Open(repoPath) - opens repo

Migration Guide

// Before
err := git.Push(repoPath, "origin", "main")
commits, err := git.Log(repoPath, "HEAD")

// After
repo, err := git.Open(repoPath)
if err != nil {
    return err
}
err := repo.Push("origin", "main")
commits, err := repo.Log("HEAD")

Stats

  • 345 deletions, 83 insertions
  • -262 net lines of code
  • 28 redundant functions removed
  • Tests updated and passing
  • CI updated to Go 1.26.x and v2 branch

Breaking Changes

This is a v2 breaking change. Any code using the removed top-level functions will need to be updated to use Repository methods.

@unknwon unknwon requested a review from a team as a code owner February 14, 2026 02:30
@unknwon unknwon force-pushed the cleanup/remove-redundant-helpers branch 3 times, most recently from 4bca19f to a61f34b Compare February 14, 2026 02:42
@unknwon unknwon changed the title cleanup: remove deprecated RepoXxx wrapper functions cleanup: consolidate all repo operations into Repository methods Feb 14, 2026
@unknwon unknwon force-pushed the cleanup/remove-redundant-helpers branch 2 times, most recently from bd96e1e to 76eb453 Compare February 14, 2026 02:50
This is a breaking change for v2 that removes all top-level functions
that take repoPath as the first parameter. These functions have been
consolidated into Repository methods.

**Removed top-level functions (use Repository methods instead):**

repo.go:
- Push(repoPath, ...) → repo.Push(...)
- Checkout(repoPath, ...) → repo.Checkout(...)
- Reset(repoPath, ...) → repo.Reset(...)
- Move(repoPath, ...) → repo.Move(...)
- Add(repoPath, ...) → repo.Add(...)
- CreateCommit(repoPath, ...) → repo.Commit(...)
- ShowNameStatus(repoPath, ...) → repo.ShowNameStatus(...)
- CountObjects(repoPath, ...) → repo.CountObjects(...)
- Fsck(repoPath, ...) → repo.Fsck(...)

repo_commit.go:
- Log(repoPath, ...) → repo.Log(...)
- DiffNameOnly(repoPath, ...) → repo.DiffNameOnly(...)

repo_pull.go:
- MergeBase(repoPath, ...) → repo.MergeBase(...)

repo_reference.go:
- ShowRefVerify(repoPath, ...) → repo.ShowRefVerify(...)
- SymbolicRef(repoPath, ...) → repo.SymbolicRef(...)
- DeleteBranch(repoPath, ...) → repo.DeleteBranch(...)
- HasReference(repoPath, ...) → repo.HasReference(...)
- HasBranch(repoPath, ...) → repo.HasBranch(...)
- HasTag(repoPath, ...) → repo.HasTag(...)

repo_remote.go:
- RemoteAdd(repoPath, ...) → repo.RemoteAdd(...)
- RemoteRemove(repoPath, ...) → repo.RemoteRemove(...)
- Remotes(repoPath, ...) → repo.Remotes(...)
- RemoteGetURL(repoPath, ...) → repo.RemoteGetURL(...)
- RemoteSetURL(repoPath, ...) → repo.RemoteSetURL(...)
- RemoteSetURLAdd(repoPath, ...) → repo.RemoteSetURLAdd(...)
- RemoteSetURLDelete(repoPath, ...) → repo.RemoteSetURLDelete(...)

repo_tag.go:
- Tags(repoPath, ...) → repo.Tags(...)

**Kept top-level functions (no repo required):**
- Init(path, ...) - creates new repo
- Clone(url, dst, ...) - clones repo
- Open(repoPath) - opens repo

**Stats:** 342 deletions, 80 insertions (-262 net lines)

All tests updated and passing.
@unknwon unknwon force-pushed the cleanup/remove-redundant-helpers branch from 76eb453 to 6e87ef2 Compare February 14, 2026 02:52
@unknwon unknwon force-pushed the cleanup/remove-redundant-helpers branch from 4d5f2af to 96df713 Compare February 14, 2026 03:05
@unknwon unknwon merged commit f2b89e0 into v2 Feb 14, 2026
4 checks passed
@unknwon unknwon deleted the cleanup/remove-redundant-helpers branch February 14, 2026 03:17
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.

1 participant