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-04-08 10:32:25 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-09 13:41:45 +0300
commitebcc3183b5f6b7770e767e9b8bac151770f70cc1 (patch)
tree88880e4f5a31aaa36d5d195e1ffc825b6f3322a0 /internal/gitaly/service/repository/apply_gitattributes.go
parentfbd748b1f4b01e66b39b639369893fd4746b2037 (diff)
transaction: Introduce Vote type
When voting, we currently only accept a byte slice representing the vote itself. This requires the caller to know how to compute the vote and thus leaks implementation details across all voters. Improve the situation by introducing a new `Vote` type, which simply maps to a fixed-size byte array, along with constructors to create a `Vote`.
Diffstat (limited to 'internal/gitaly/service/repository/apply_gitattributes.go')
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/gitaly/service/repository/apply_gitattributes.go b/internal/gitaly/service/repository/apply_gitattributes.go
index 6f7190b26..7a876fb81 100644
--- a/internal/gitaly/service/repository/apply_gitattributes.go
+++ b/internal/gitaly/service/repository/apply_gitattributes.go
@@ -11,6 +11,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/praefect/metadata"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -107,7 +108,12 @@ func (s *server) vote(ctx context.Context, oid git.ObjectID) error {
return fmt.Errorf("vote with invalid object ID: %w", err)
}
- if err := s.txManager.Vote(ctx, tx, *praefect, hash); err != nil {
+ vote, err := transaction.VoteFromHash(hash)
+ if err != nil {
+ return fmt.Errorf("cannot convert OID to vote: %w", err)
+ }
+
+ if err := s.txManager.Vote(ctx, tx, *praefect, vote); err != nil {
return fmt.Errorf("vote failed: %w", err)
}