Skip to content

Commit 999409b

Browse files
committed
cleanup: remove deprecated RepoXxx wrapper functions
Remove all deprecated functions and inconsistent naming: **Removed deprecated wrappers:** - RepoPush, RepoCheckout, RepoReset, RepoMove, RepoAdd, RepoCommit - RepoShowNameStatus, RepoCountObjects, RepoFsck - RepoLog, RepoDiffNameOnly - RepoShowRefVerify, RepoHasTag, RepoDeleteBranch - RepoAddRemote, RepoRemoveRemote, RepoMergeBase **Renamed for consistency:** - RepoHasReference → HasReference - RepoHasBranch → HasBranch - RepoTags → Tags **Removed type aliases:** - AddRemoteOptions (use RemoteAddOptions) - RemoveRemoteOptions (use RemoteRemoveOptions) **Removed method aliases:** - (*Repository).AddRemote (use RemoteAdd) - (*Repository).RemoveRemote (use RemoteRemove) This reduces the API surface and eliminates tech debt for v2. The recommended pattern is either top-level functions or Repository methods.
1 parent 20722b9 commit 999409b

6 files changed

Lines changed: 11 additions & 112 deletions

File tree

repo.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,6 @@ func Push(repoPath, remote, branch string, opts ...PushOptions) error {
266266
return err
267267
}
268268

269-
// Deprecated: Use Push instead.
270-
func RepoPush(repoPath, remote, branch string, opts ...PushOptions) error {
271-
return Push(repoPath, remote, branch, opts...)
272-
}
273-
274269
// Push pushes local changes to given remote and branch for the repository.
275270
func (r *Repository) Push(remote, branch string, opts ...PushOptions) error {
276271
return Push(r.path, remote, branch, opts...)
@@ -311,11 +306,6 @@ func Checkout(repoPath, branch string, opts ...CheckoutOptions) error {
311306
return err
312307
}
313308

314-
// Deprecated: Use Checkout instead.
315-
func RepoCheckout(repoPath, branch string, opts ...CheckoutOptions) error {
316-
return Checkout(repoPath, branch, opts...)
317-
}
318-
319309
// Checkout checks out to given branch for the repository.
320310
func (r *Repository) Checkout(branch string, opts ...CheckoutOptions) error {
321311
return Checkout(r.path, branch, opts...)
@@ -352,11 +342,6 @@ func Reset(repoPath, rev string, opts ...ResetOptions) error {
352342
return err
353343
}
354344

355-
// Deprecated: Use Reset instead.
356-
func RepoReset(repoPath, rev string, opts ...ResetOptions) error {
357-
return Reset(repoPath, rev, opts...)
358-
}
359-
360345
// Reset resets working tree to given revision for the repository.
361346
func (r *Repository) Reset(rev string, opts ...ResetOptions) error {
362347
return Reset(r.path, rev, opts...)
@@ -388,11 +373,6 @@ func Move(repoPath, src, dst string, opts ...MoveOptions) error {
388373
return err
389374
}
390375

391-
// Deprecated: Use Move instead.
392-
func RepoMove(repoPath, src, dst string, opts ...MoveOptions) error {
393-
return Move(repoPath, src, dst, opts...)
394-
}
395-
396376
// Move moves a file, a directory, or a symlink file or directory from source to
397377
// destination for the repository.
398378
func (r *Repository) Move(src, dst string, opts ...MoveOptions) error {
@@ -435,11 +415,6 @@ func Add(repoPath string, opts ...AddOptions) error {
435415
return err
436416
}
437417

438-
// Deprecated: Use Add instead.
439-
func RepoAdd(repoPath string, opts ...AddOptions) error {
440-
return Add(repoPath, opts...)
441-
}
442-
443418
// Add adds local changes to index for the repository.
444419
func (r *Repository) Add(opts ...AddOptions) error {
445420
return Add(r.path, opts...)
@@ -486,11 +461,6 @@ func CreateCommit(repoPath string, committer *Signature, message string, opts ..
486461
return err
487462
}
488463

489-
// Deprecated: Use CreateCommit instead.
490-
func RepoCommit(repoPath string, committer *Signature, message string, opts ...CommitOptions) error {
491-
return CreateCommit(repoPath, committer, message, opts...)
492-
}
493-
494464
// Commit commits local changes with given author, committer and message for the
495465
// repository.
496466
func (r *Repository) Commit(committer *Signature, message string, opts ...CommitOptions) error {
@@ -562,11 +532,6 @@ func ShowNameStatus(repoPath, rev string, opts ...ShowNameStatusOptions) (*NameS
562532
return fileStatus, nil
563533
}
564534

565-
// Deprecated: Use ShowNameStatus instead.
566-
func RepoShowNameStatus(repoPath, rev string, opts ...ShowNameStatusOptions) (*NameStatus, error) {
567-
return ShowNameStatus(repoPath, rev, opts...)
568-
}
569-
570535
// ShowNameStatus returns name status of given revision of the repository.
571536
func (r *Repository) ShowNameStatus(rev string, opts ...ShowNameStatusOptions) (*NameStatus, error) {
572537
return ShowNameStatus(r.path, rev, opts...)
@@ -675,11 +640,6 @@ func CountObjects(repoPath string, opts ...CountObjectsOptions) (*CountObject, e
675640
return countObject, nil
676641
}
677642

678-
// Deprecated: Use CountObjects instead.
679-
func RepoCountObjects(repoPath string, opts ...CountObjectsOptions) (*CountObject, error) {
680-
return CountObjects(repoPath, opts...)
681-
}
682-
683643
// CountObjects returns disk usage report of the repository.
684644
func (r *Repository) CountObjects(opts ...CountObjectsOptions) (*CountObject, error) {
685645
return CountObjects(r.path, opts...)
@@ -711,11 +671,6 @@ func Fsck(repoPath string, opts ...FsckOptions) error {
711671
return err
712672
}
713673

714-
// Deprecated: Use Fsck instead.
715-
func RepoFsck(repoPath string, opts ...FsckOptions) error {
716-
return Fsck(repoPath, opts...)
717-
}
718-
719674
// Fsck verifies the connectivity and validity of the objects in the database
720675
// for the repository.
721676
func (r *Repository) Fsck(opts ...FsckOptions) error {

repo_commit.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,6 @@ func Log(repoPath, rev string, opts ...LogOptions) ([]*Commit, error) {
206206
return r.Log(rev, opts...)
207207
}
208208

209-
// Deprecated: Use Log instead.
210-
func RepoLog(repoPath, rev string, opts ...LogOptions) ([]*Commit, error) {
211-
return Log(repoPath, rev, opts...)
212-
}
213-
214209
// Log returns a list of commits in the state of given revision of the repository.
215210
// The returned list is in reverse chronological order.
216211
func (r *Repository) Log(rev string, opts ...LogOptions) ([]*Commit, error) {
@@ -434,11 +429,6 @@ func DiffNameOnly(repoPath, base, head string, opts ...DiffNameOnlyOptions) ([]s
434429
return names, nil
435430
}
436431

437-
// Deprecated: Use DiffNameOnly instead.
438-
func RepoDiffNameOnly(repoPath, base, head string, opts ...DiffNameOnlyOptions) ([]string, error) {
439-
return DiffNameOnly(repoPath, base, head, opts...)
440-
}
441-
442432
// DiffNameOnly returns a list of changed files between base and head revisions of the
443433
// repository.
444434
func (r *Repository) DiffNameOnly(base, head string, opts ...DiffNameOnlyOptions) ([]string, error) {

repo_pull.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ func MergeBase(repoPath, base, head string, opts ...MergeBaseOptions) (string, e
4646
return strings.TrimSpace(string(stdout)), nil
4747
}
4848

49-
// Deprecated: Use MergeBase instead.
50-
func RepoMergeBase(repoPath, base, head string, opts ...MergeBaseOptions) (string, error) {
51-
return MergeBase(repoPath, base, head, opts...)
52-
}
53-
5449
// MergeBase returns merge base between base and head revisions of the
5550
// repository.
5651
func (r *Repository) MergeBase(base, head string, opts ...MergeBaseOptions) (string, error) {

repo_reference.go

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ func ShowRefVerify(repoPath, ref string, opts ...ShowRefVerifyOptions) (string,
6767
return strings.Split(string(stdout), " ")[0], nil
6868
}
6969

70-
// Deprecated: Use ShowRefVerify instead.
71-
func RepoShowRefVerify(repoPath, ref string, opts ...ShowRefVerifyOptions) (string, error) {
72-
return ShowRefVerify(repoPath, ref, opts...)
73-
}
74-
7570
// ShowRefVerify returns the commit ID of given reference (e.g.
7671
// "refs/heads/master") if it exists in the repository.
7772
func (r *Repository) ShowRefVerify(ref string, opts ...ShowRefVerifyOptions) (string, error) {
@@ -90,41 +85,36 @@ func (r *Repository) TagCommitID(tag string, opts ...ShowRefVerifyOptions) (stri
9085
return r.ShowRefVerify(RefsTags+tag, opts...)
9186
}
9287

93-
// RepoHasReference returns true if given reference exists in the repository in
88+
// HasReference returns true if given reference exists in the repository in
9489
// given path. The reference must be given in full refspec, e.g.
9590
// "refs/heads/master".
96-
func RepoHasReference(repoPath, ref string, opts ...ShowRefVerifyOptions) bool {
91+
func HasReference(repoPath, ref string, opts ...ShowRefVerifyOptions) bool {
9792
_, err := ShowRefVerify(repoPath, ref, opts...)
9893
return err == nil
9994
}
10095

101-
// RepoHasBranch returns true if given branch exists in the repository in given
96+
// HasBranch returns true if given branch exists in the repository in given
10297
// path. The branch must be given in short name e.g. "master".
103-
func RepoHasBranch(repoPath, branch string, opts ...ShowRefVerifyOptions) bool {
104-
return RepoHasReference(repoPath, RefsHeads+branch, opts...)
98+
func HasBranch(repoPath, branch string, opts ...ShowRefVerifyOptions) bool {
99+
return HasReference(repoPath, RefsHeads+branch, opts...)
105100
}
106101

107102
// HasTag returns true if given tag exists in the repository in given path. The
108103
// tag must be given in short name e.g. "v1.0.0".
109104
func HasTag(repoPath, tag string, opts ...ShowRefVerifyOptions) bool {
110-
return RepoHasReference(repoPath, RefsTags+tag, opts...)
111-
}
112-
113-
// Deprecated: Use HasTag instead.
114-
func RepoHasTag(repoPath, tag string, opts ...ShowRefVerifyOptions) bool {
115-
return HasTag(repoPath, tag, opts...)
105+
return HasReference(repoPath, RefsTags+tag, opts...)
116106
}
117107

118108
// HasReference returns true if given reference exists in the repository. The
119109
// reference must be given in full refspec, e.g. "refs/heads/master".
120110
func (r *Repository) HasReference(ref string, opts ...ShowRefVerifyOptions) bool {
121-
return RepoHasReference(r.path, ref, opts...)
111+
return HasReference(r.path, ref, opts...)
122112
}
123113

124114
// HasBranch returns true if given branch exists in the repository. The branch
125115
// must be given in short name e.g. "master".
126116
func (r *Repository) HasBranch(branch string, opts ...ShowRefVerifyOptions) bool {
127-
return RepoHasBranch(r.path, branch, opts...)
117+
return HasBranch(r.path, branch, opts...)
128118
}
129119

130120
// HasTag returns true if given tag exists in the repository. The tag must be
@@ -285,11 +275,6 @@ func DeleteBranch(repoPath, name string, opts ...DeleteBranchOptions) error {
285275
return err
286276
}
287277

288-
// Deprecated: Use DeleteBranch instead.
289-
func RepoDeleteBranch(repoPath, name string, opts ...DeleteBranchOptions) error {
290-
return DeleteBranch(repoPath, name, opts...)
291-
}
292-
293278
// DeleteBranch deletes the branch from the repository.
294279
func (r *Repository) DeleteBranch(name string, opts ...DeleteBranchOptions) error {
295280
return DeleteBranch(r.path, name, opts...)

repo_remote.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ type RemoteAddOptions struct {
103103
CommandOptions
104104
}
105105

106-
// Deprecated: Use RemoteAddOptions instead.
107-
type AddRemoteOptions = RemoteAddOptions
108-
109106
// RemoteAdd adds a new remote to the repository in given path.
110107
func RemoteAdd(repoPath, name, url string, opts ...RemoteAddOptions) error {
111108
var opt RemoteAddOptions
@@ -125,21 +122,11 @@ func RemoteAdd(repoPath, name, url string, opts ...RemoteAddOptions) error {
125122
return err
126123
}
127124

128-
// Deprecated: Use RemoteAdd instead.
129-
func RepoAddRemote(repoPath, name, url string, opts ...RemoteAddOptions) error {
130-
return RemoteAdd(repoPath, name, url, opts...)
131-
}
132-
133125
// RemoteAdd adds a new remote to the repository.
134126
func (r *Repository) RemoteAdd(name, url string, opts ...RemoteAddOptions) error {
135127
return RemoteAdd(r.path, name, url, opts...)
136128
}
137129

138-
// Deprecated: Use RemoteAdd instead.
139-
func (r *Repository) AddRemote(name, url string, opts ...RemoteAddOptions) error {
140-
return RemoteAdd(r.path, name, url, opts...)
141-
}
142-
143130
// RemoteRemoveOptions contains arguments for removing a remote from the
144131
// repository.
145132
//
@@ -154,9 +141,6 @@ type RemoteRemoveOptions struct {
154141
CommandOptions
155142
}
156143

157-
// Deprecated: Use RemoteRemoveOptions instead.
158-
type RemoveRemoteOptions = RemoteRemoveOptions
159-
160144
// RemoteRemove removes a remote from the repository in given path.
161145
func RemoteRemove(repoPath, name string, opts ...RemoteRemoveOptions) error {
162146
var opt RemoteRemoveOptions
@@ -179,21 +163,11 @@ func RemoteRemove(repoPath, name string, opts ...RemoteRemoveOptions) error {
179163
return nil
180164
}
181165

182-
// Deprecated: Use RemoteRemove instead.
183-
func RepoRemoveRemote(repoPath, name string, opts ...RemoteRemoveOptions) error {
184-
return RemoteRemove(repoPath, name, opts...)
185-
}
186-
187166
// RemoteRemove removes a remote from the repository.
188167
func (r *Repository) RemoteRemove(name string, opts ...RemoteRemoveOptions) error {
189168
return RemoteRemove(r.path, name, opts...)
190169
}
191170

192-
// Deprecated: Use RemoteRemove instead.
193-
func (r *Repository) RemoveRemote(name string, opts ...RemoteRemoveOptions) error {
194-
return RemoteRemove(r.path, name, opts...)
195-
}
196-
197171
// RemotesOptions contains arguments for listing remotes of the repository.
198172
// /
199173
// Docs: https://git-scm.com/docs/git-remote#_commands

repo_tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ type TagsOptions struct {
159159
CommandOptions
160160
}
161161

162-
// RepoTags returns a list of tags of the repository in given path.
163-
func RepoTags(repoPath string, opts ...TagsOptions) ([]string, error) {
162+
// Tags returns a list of tags of the repository in given path.
163+
func Tags(repoPath string, opts ...TagsOptions) ([]string, error) {
164164
var opt TagsOptions
165165
if len(opts) > 0 {
166166
opt = opts[0]
@@ -191,7 +191,7 @@ func RepoTags(repoPath string, opts ...TagsOptions) ([]string, error) {
191191

192192
// Tags returns a list of tags of the repository.
193193
func (r *Repository) Tags(opts ...TagsOptions) ([]string, error) {
194-
return RepoTags(r.path, opts...)
194+
return Tags(r.path, opts...)
195195
}
196196

197197
// CreateTagOptions contains optional arguments for creating a tag.

0 commit comments

Comments
 (0)