diff options
author | Stan Hu <stanhu@gmail.com> | 2021-06-29 00:55:46 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2021-06-29 09:11:35 +0300 |
commit | b9f207cb6160e1e6c98cc8e369b8862d6b123d33 (patch) | |
tree | 9bc2f920f3f279d20eb13bead796ecdb27760481 | |
parent | a17eb2f677f9710ee46ac4a9007b0cd828ca389a (diff) |
Rename UpdateReferenceWithHooks -> UpdateReference
Since this method is inside a struct called UpdaterWithHooks, we can
simplify the method name.
-rw-r--r-- | internal/git/updateref/update_with_hooks.go | 12 | ||||
-rw-r--r-- | internal/git/updateref/update_with_hooks_test.go | 8 | ||||
-rw-r--r-- | internal/gitaly/service/operations/update_with_hooks.go | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/internal/git/updateref/update_with_hooks.go b/internal/git/updateref/update_with_hooks.go index f8bb13841..e8a7bbc37 100644 --- a/internal/git/updateref/update_with_hooks.go +++ b/internal/git/updateref/update_with_hooks.go @@ -57,7 +57,7 @@ func hookErrorMessage(sout string, serr string, err error) string { return sout } -// NewUpdaterWithHooks creates a new instance of a class that will update a Git branch +// NewUpdaterWithHooks creates a new instance of a struct that will update a Git reference. func NewUpdaterWithHooks( cfg config.Cfg, hookManager hook.Manager, @@ -72,8 +72,8 @@ func NewUpdaterWithHooks( } } -// UpdateReferenceWithHooks updates a branch with a given commit ID using the Git hooks -func (u *UpdaterWithHooks) UpdateReferenceWithHooks( +// UpdateReference updates a branch with a given commit ID using the Git hooks +func (u *UpdaterWithHooks) UpdateReference( ctx context.Context, repo *gitalypb.Repository, user *gitalypb.User, @@ -98,13 +98,13 @@ func (u *UpdaterWithHooks) UpdateReferenceWithHooks( } if reference == "" { - return helper.ErrInternalf("updateReferenceWithHooks: got no reference") + return helper.ErrInternalf("UpdateReference: got no reference") } if err := git.ValidateObjectID(oldrev.String()); err != nil { - return helper.ErrInternalf("updateReferenceWithHooks: got invalid old value: %w", err) + return helper.ErrInternalf("UpdateReference: got invalid old value: %w", err) } if err := git.ValidateObjectID(newrev.String()); err != nil { - return helper.ErrInternalf("updateReferenceWithHooks: got invalid new value: %w", err) + return helper.ErrInternalf("UpdateReference: got invalid new value: %w", err) } env := []string{ diff --git a/internal/git/updateref/update_with_hooks_test.go b/internal/git/updateref/update_with_hooks_test.go index 831630183..bb3e3c99f 100644 --- a/internal/git/updateref/update_with_hooks_test.go +++ b/internal/git/updateref/update_with_hooks_test.go @@ -48,7 +48,7 @@ func (m *mockHookManager) ReferenceTransactionHook(ctx context.Context, state ho return m.referenceTransaction(m.t, ctx, state, env, stdin) } -func TestUpdateReferenceWithHooks_invalidParameters(t *testing.T) { +func TestUpdaterWithHooks_UpdateReference_invalidParameters(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() @@ -107,13 +107,13 @@ func TestUpdateReferenceWithHooks_invalidParameters(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - err := updater.UpdateReferenceWithHooks(ctx, repo, user, tc.ref, tc.newRev, tc.oldRev) + err := updater.UpdateReference(ctx, repo, user, tc.ref, tc.newRev, tc.oldRev) require.Contains(t, err.Error(), tc.expectedErr) }) } } -func TestUpdateReferenceWithHooks(t *testing.T) { +func TestUpdaterWithHooks_UpdateReference(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() @@ -277,7 +277,7 @@ func TestUpdateReferenceWithHooks(t *testing.T) { gitCmdFactory := git.NewExecCommandFactory(cfg) updater := NewUpdaterWithHooks(cfg, hookManager, gitCmdFactory, nil) - err := updater.UpdateReferenceWithHooks(ctx, repo, user, git.ReferenceName("refs/heads/master"), git.ZeroOID, git.ObjectID(oldRev)) + err := updater.UpdateReference(ctx, repo, user, git.ReferenceName("refs/heads/master"), git.ZeroOID, git.ObjectID(oldRev)) if tc.expectedErr == "" { require.NoError(t, err) } else { diff --git a/internal/gitaly/service/operations/update_with_hooks.go b/internal/gitaly/service/operations/update_with_hooks.go index b4ada473c..d0bffacf4 100644 --- a/internal/gitaly/service/operations/update_with_hooks.go +++ b/internal/gitaly/service/operations/update_with_hooks.go @@ -15,5 +15,5 @@ func (s *Server) updateReferenceWithHooks( newrev, oldrev git.ObjectID, pushOptions ...string, ) error { - return s.updater.UpdateReferenceWithHooks(ctx, repo, user, reference, newrev, oldrev, pushOptions...) + return s.updater.UpdateReference(ctx, repo, user, reference, newrev, oldrev, pushOptions...) } |