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

ref.go « git « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b802229e8e2f39d3498215b21fb33877c5cf6718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package git

import (
	"context"

	"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)

// IsValidRef checks if a ref in a repo is valid
func IsValidRef(ctx context.Context, repo *gitalypb.Repository, ref string) bool {
	if ref == "" {
		return false
	}

	cmd, err := unsafeCmd(ctx, repo, "log", "--max-count=1", ref)
	if err != nil {
		return false
	}

	return cmd.Wait() == nil
}