@@ -253,29 +253,18 @@ type PushOptions struct {
253253 CommandOptions
254254}
255255
256- // Push pushes local changes to given remote and branch for the repository in
257- // given path.
258- func Push (repoPath , remote , branch string , opts ... PushOptions ) error {
256+ // Push pushes local changes to given remote and branch for the repository.
257+ func (r * Repository ) Push (remote , branch string , opts ... PushOptions ) error {
259258 var opt PushOptions
260259 if len (opts ) > 0 {
261260 opt = opts [0 ]
262261 }
263262
264263 cmd := NewCommand ("push" ).AddOptions (opt .CommandOptions ).AddArgs ("--end-of-options" , remote , branch )
265- _ , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
264+ _ , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
266265 return err
267266}
268267
269- // Deprecated: Use Push instead.
270- func RepoPush (repoPath , remote , branch string , opts ... PushOptions ) error {
271- return Push (repoPath , remote , branch , opts ... )
272- }
273-
274- // Push pushes local changes to given remote and branch for the repository.
275- func (r * Repository ) Push (remote , branch string , opts ... PushOptions ) error {
276- return Push (r .path , remote , branch , opts ... )
277- }
278-
279268// CheckoutOptions contains optional arguments for checking out to a branch.
280269//
281270// Docs: https://git-scm.com/docs/git-checkout
@@ -291,8 +280,8 @@ type CheckoutOptions struct {
291280 CommandOptions
292281}
293282
294- // Checkout checks out to given branch for the repository in given path .
295- func Checkout ( repoPath , branch string , opts ... CheckoutOptions ) error {
283+ // Checkout checks out to given branch for the repository.
284+ func ( r * Repository ) Checkout ( branch string , opts ... CheckoutOptions ) error {
296285 var opt CheckoutOptions
297286 if len (opts ) > 0 {
298287 opt = opts [0 ]
@@ -307,20 +296,10 @@ func Checkout(repoPath, branch string, opts ...CheckoutOptions) error {
307296 cmd .AddArgs (opt .BaseBranch )
308297 }
309298
310- _ , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
299+ _ , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
311300 return err
312301}
313302
314- // Deprecated: Use Checkout instead.
315- func RepoCheckout (repoPath , branch string , opts ... CheckoutOptions ) error {
316- return Checkout (repoPath , branch , opts ... )
317- }
318-
319- // Checkout checks out to given branch for the repository.
320- func (r * Repository ) Checkout (branch string , opts ... CheckoutOptions ) error {
321- return Checkout (r .path , branch , opts ... )
322- }
323-
324303// ResetOptions contains optional arguments for resetting a branch.
325304//
326305// Docs: https://git-scm.com/docs/git-reset
@@ -336,8 +315,8 @@ type ResetOptions struct {
336315 CommandOptions
337316}
338317
339- // Reset resets working tree to given revision for the repository in given path .
340- func Reset ( repoPath , rev string , opts ... ResetOptions ) error {
318+ // Reset resets working tree to given revision for the repository.
319+ func ( r * Repository ) Reset ( rev string , opts ... ResetOptions ) error {
341320 var opt ResetOptions
342321 if len (opts ) > 0 {
343322 opt = opts [0 ]
@@ -348,20 +327,10 @@ func Reset(repoPath, rev string, opts ...ResetOptions) error {
348327 cmd .AddArgs ("--hard" )
349328 }
350329
351- _ , err := cmd .AddOptions (opt .CommandOptions ).AddArgs ("--end-of-options" , rev ).RunInDir (repoPath )
330+ _ , err := cmd .AddOptions (opt .CommandOptions ).AddArgs ("--end-of-options" , rev ).RunInDir (r . path )
352331 return err
353332}
354333
355- // Deprecated: Use Reset instead.
356- func RepoReset (repoPath , rev string , opts ... ResetOptions ) error {
357- return Reset (repoPath , rev , opts ... )
358- }
359-
360- // Reset resets working tree to given revision for the repository.
361- func (r * Repository ) Reset (rev string , opts ... ResetOptions ) error {
362- return Reset (r .path , rev , opts ... )
363- }
364-
365334// MoveOptions contains optional arguments for moving a file, a directory, or a
366335// symlink.
367336//
@@ -377,28 +346,17 @@ type MoveOptions struct {
377346}
378347
379348// Move moves a file, a directory, or a symlink file or directory from source to
380- // destination for the repository in given path .
381- func Move ( repoPath , src , dst string , opts ... MoveOptions ) error {
349+ // destination for the repository.
350+ func ( r * Repository ) Move ( src , dst string , opts ... MoveOptions ) error {
382351 var opt MoveOptions
383352 if len (opts ) > 0 {
384353 opt = opts [0 ]
385354 }
386355
387- _ , err := NewCommand ("mv" ).AddOptions (opt .CommandOptions ).AddArgs ("--end-of-options" , src , dst ).RunInDirWithTimeout (opt .Timeout , repoPath )
356+ _ , err := NewCommand ("mv" ).AddOptions (opt .CommandOptions ).AddArgs ("--end-of-options" , src , dst ).RunInDirWithTimeout (opt .Timeout , r . path )
388357 return err
389358}
390359
391- // Deprecated: Use Move instead.
392- func RepoMove (repoPath , src , dst string , opts ... MoveOptions ) error {
393- return Move (repoPath , src , dst , opts ... )
394- }
395-
396- // Move moves a file, a directory, or a symlink file or directory from source to
397- // destination for the repository.
398- func (r * Repository ) Move (src , dst string , opts ... MoveOptions ) error {
399- return Move (r .path , src , dst , opts ... )
400- }
401-
402360// AddOptions contains optional arguments for adding local changes.
403361//
404362// Docs: https://git-scm.com/docs/git-add
@@ -416,8 +374,8 @@ type AddOptions struct {
416374 CommandOptions
417375}
418376
419- // Add adds local changes to index for the repository in given path .
420- func Add ( repoPath string , opts ... AddOptions ) error {
377+ // Add adds local changes to index for the repository.
378+ func ( r * Repository ) Add ( opts ... AddOptions ) error {
421379 var opt AddOptions
422380 if len (opts ) > 0 {
423381 opt = opts [0 ]
@@ -431,20 +389,10 @@ func Add(repoPath string, opts ...AddOptions) error {
431389 cmd .AddArgs ("--" )
432390 cmd .AddArgs (opt .Pathspecs ... )
433391 }
434- _ , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
392+ _ , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
435393 return err
436394}
437395
438- // Deprecated: Use Add instead.
439- func RepoAdd (repoPath string , opts ... AddOptions ) error {
440- return Add (repoPath , opts ... )
441- }
442-
443- // Add adds local changes to index for the repository.
444- func (r * Repository ) Add (opts ... AddOptions ) error {
445- return Add (r .path , opts ... )
446- }
447-
448396// CommitOptions contains optional arguments to commit changes.
449397//
450398// Docs: https://git-scm.com/docs/git-commit
@@ -460,9 +408,9 @@ type CommitOptions struct {
460408 CommandOptions
461409}
462410
463- // CreateCommit commits local changes with given author, committer and message
464- // for the repository in given path .
465- func CreateCommit ( repoPath string , committer * Signature , message string , opts ... CommitOptions ) error {
411+ // Commit commits local changes with given author, committer and message for the
412+ // repository.
413+ func ( r * Repository ) Commit ( committer * Signature , message string , opts ... CommitOptions ) error {
466414 var opt CommitOptions
467415 if len (opts ) > 0 {
468416 opt = opts [0 ]
@@ -478,25 +426,14 @@ func CreateCommit(repoPath string, committer *Signature, message string, opts ..
478426 AddArgs ("-m" , message ).
479427 AddOptions (opt .CommandOptions )
480428
481- _ , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
429+ _ , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
482430 // No stderr but exit status 1 means nothing to commit.
483431 if err != nil && err .Error () == "exit status 1" {
484432 return nil
485433 }
486434 return err
487435}
488436
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-
494- // Commit commits local changes with given author, committer and message for the
495- // repository.
496- func (r * Repository ) Commit (committer * Signature , message string , opts ... CommitOptions ) error {
497- return CreateCommit (r .path , committer , message , opts ... )
498- }
499-
500437// NameStatus contains name status of a commit.
501438type NameStatus struct {
502439 Added []string
@@ -517,9 +454,8 @@ type ShowNameStatusOptions struct {
517454 CommandOptions
518455}
519456
520- // ShowNameStatus returns name status of given revision of the repository in
521- // given path.
522- func ShowNameStatus (repoPath , rev string , opts ... ShowNameStatusOptions ) (* NameStatus , error ) {
457+ // ShowNameStatus returns name status of given revision of the repository.
458+ func (r * Repository ) ShowNameStatus (rev string , opts ... ShowNameStatusOptions ) (* NameStatus , error ) {
523459 var opt ShowNameStatusOptions
524460 if len (opts ) > 0 {
525461 opt = opts [0 ]
@@ -552,7 +488,7 @@ func ShowNameStatus(repoPath, rev string, opts ...ShowNameStatusOptions) (*NameS
552488 cmd := NewCommand ("show" , "--name-status" , "--pretty=format:''" ).
553489 AddOptions (opt .CommandOptions ).
554490 AddArgs ("--end-of-options" , rev )
555- err := cmd .RunInDirPipelineWithTimeout (opt .Timeout , w , stderr , repoPath )
491+ err := cmd .RunInDirPipelineWithTimeout (opt .Timeout , w , stderr , r . path )
556492 _ = w .Close () // Close writer to exit parsing goroutine
557493 if err != nil {
558494 return nil , concatenateError (err , stderr .String ())
@@ -562,16 +498,6 @@ func ShowNameStatus(repoPath, rev string, opts ...ShowNameStatusOptions) (*NameS
562498 return fileStatus , nil
563499}
564500
565- // Deprecated: Use ShowNameStatus instead.
566- func RepoShowNameStatus (repoPath , rev string , opts ... ShowNameStatusOptions ) (* NameStatus , error ) {
567- return ShowNameStatus (repoPath , rev , opts ... )
568- }
569-
570- // ShowNameStatus returns name status of given revision of the repository.
571- func (r * Repository ) ShowNameStatus (rev string , opts ... ShowNameStatusOptions ) (* NameStatus , error ) {
572- return ShowNameStatus (r .path , rev , opts ... )
573- }
574-
575501// RevParseOptions contains optional arguments for parsing revision.
576502//
577503// Docs: https://git-scm.com/docs/git-rev-parse
@@ -631,16 +557,16 @@ type CountObjectsOptions struct {
631557 CommandOptions
632558}
633559
634- // CountObjects returns disk usage report of the repository in given path .
635- func CountObjects ( repoPath string , opts ... CountObjectsOptions ) (* CountObject , error ) {
560+ // CountObjects returns disk usage report of the repository.
561+ func ( r * Repository ) CountObjects ( opts ... CountObjectsOptions ) (* CountObject , error ) {
636562 var opt CountObjectsOptions
637563 if len (opts ) > 0 {
638564 opt = opts [0 ]
639565 }
640566
641567 stdout , err := NewCommand ("count-objects" , "-v" ).
642568 AddOptions (opt .CommandOptions ).
643- RunInDirWithTimeout (opt .Timeout , repoPath )
569+ RunInDirWithTimeout (opt .Timeout , r . path )
644570 if err != nil {
645571 return nil , err
646572 }
@@ -675,16 +601,6 @@ func CountObjects(repoPath string, opts ...CountObjectsOptions) (*CountObject, e
675601 return countObject , nil
676602}
677603
678- // Deprecated: Use CountObjects instead.
679- func RepoCountObjects (repoPath string , opts ... CountObjectsOptions ) (* CountObject , error ) {
680- return CountObjects (repoPath , opts ... )
681- }
682-
683- // CountObjects returns disk usage report of the repository.
684- func (r * Repository ) CountObjects (opts ... CountObjectsOptions ) (* CountObject , error ) {
685- return CountObjects (r .path , opts ... )
686- }
687-
688604// FsckOptions contains optional arguments for verifying the objects.
689605//
690606// Docs: https://git-scm.com/docs/git-fsck
@@ -699,25 +615,14 @@ type FsckOptions struct {
699615}
700616
701617// Fsck verifies the connectivity and validity of the objects in the database
702- // for the repository in given path .
703- func Fsck ( repoPath string , opts ... FsckOptions ) error {
618+ // for the repository.
619+ func ( r * Repository ) Fsck ( opts ... FsckOptions ) error {
704620 var opt FsckOptions
705621 if len (opts ) > 0 {
706622 opt = opts [0 ]
707623 }
708624
709625 cmd := NewCommand ("fsck" ).AddOptions (opt .CommandOptions )
710- _ , err := cmd .RunInDirWithTimeout (opt .Timeout , repoPath )
626+ _ , err := cmd .RunInDirWithTimeout (opt .Timeout , r . path )
711627 return err
712628}
713-
714- // Deprecated: Use Fsck instead.
715- func RepoFsck (repoPath string , opts ... FsckOptions ) error {
716- return Fsck (repoPath , opts ... )
717- }
718-
719- // Fsck verifies the connectivity and validity of the objects in the database
720- // for the repository.
721- func (r * Repository ) Fsck (opts ... FsckOptions ) error {
722- return Fsck (r .path , opts ... )
723- }
0 commit comments