INNER CODE UNIT · Go

latestTag

platform-engineering-labs/formae · cmd/bundle-examples/main.go:235

func latestTag(gitURL string) (tag, sha string, err error) {
	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()
	out, err := exec.CommandContext(ctx, "git", "ls-remote", "--tags", gitURL).Output()
	if err != nil {
		return "", "", fmt.Errorf("git ls-remote %s: %w", gitURL, err)
	}
	plain := map[string]string{}
	deref := map[string]string{}
	seen := map[string]bool{}
	var tags []string
	for _, line := range strings.Split(string(out), "\n") {
		fields := strings.Fields(line)
		if len(fields) != 2 {
			continue
		}
		refSHA, ref := fields[0], fields[1]
		i := strings.LastIndex(ref, "refs/tags/")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…