Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-01-11 12:18:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-01-12 14:28:27 +0300
commit53c1d9f4bce9a8eebe9219bc5068e4bc4141de09 (patch)
treed21a1acb6ffb55f7176206cde5f446be54ce8660 /internal/gitaly/service/operations
parent01ba5b2c1c0719d27aced511bd9497b56cd9384a (diff)
operations: Move `hookErrorFromStdoutAndStderr()` to where it's used
The `hookErrorFromStdoutAndStderr()` function is used to generate a proper error message when execution of hooks fails. It's thus only used for `updateReferenceWithHooks()`. But since this function has been moved into its own "update_with_hooks.go" file in ff5805ed0 (operations: Move update with hook logic into own file, 2020-11-26) , both functions are located quite far apart from each other. Move `hookErrorFromStdoutAndStderr()` into "update_with_hooks.go" to make code more localized and easier to understand.
Diffstat (limited to 'internal/gitaly/service/operations')
-rw-r--r--internal/gitaly/service/operations/merge.go7
-rw-r--r--internal/gitaly/service/operations/update_with_hooks.go7
2 files changed, 7 insertions, 7 deletions
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index 6dd16f82a..25e8dc533 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -89,13 +89,6 @@ func validateMergeBranchRequest(request *gitalypb.UserMergeBranchRequest) error
return nil
}
-func hookErrorFromStdoutAndStderr(sout string, serr string) string {
- if len(strings.TrimSpace(serr)) > 0 {
- return serr
- }
- return sout
-}
-
func (s *Server) userMergeBranch(stream gitalypb.OperationService_UserMergeBranchServer) error {
ctx := stream.Context()
diff --git a/internal/gitaly/service/operations/update_with_hooks.go b/internal/gitaly/service/operations/update_with_hooks.go
index 55021714b..880359871 100644
--- a/internal/gitaly/service/operations/update_with_hooks.go
+++ b/internal/gitaly/service/operations/update_with_hooks.go
@@ -30,6 +30,13 @@ func (e updateRefError) Error() string {
return fmt.Sprintf("Could not update %s. Please refresh and try again.", e.reference)
}
+func hookErrorFromStdoutAndStderr(sout string, serr string) string {
+ if len(strings.TrimSpace(serr)) > 0 {
+ return serr
+ }
+ return sout
+}
+
func (s *Server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Repository, user *gitalypb.User, reference, newrev, oldrev string) error {
transaction, praefect, err := metadata.TransactionMetadataFromContext(ctx)
if err != nil {