Skip to content

Commit

Permalink
wip: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Sep 10, 2024
1 parent daf37df commit 4271ef7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 0 additions & 8 deletions forge/cli/cmd/cmds/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log/slog"
"strings"

"github.com/go-git/go-git/v5/plumbing"
"github.com/input-output-hk/catalyst-forge/blueprint/schema"
"github.com/input-output-hk/catalyst-forge/forge/cli/pkg/tag"
)
Expand Down Expand Up @@ -44,13 +43,6 @@ func (c *TagCmd) Run(logger *slog.Logger) error {
return err
}

// Check if the HEAD is detached
if ref.Name() != plumbing.HEAD {
fmt.Println("We are on a branch:", ref.Name())
} else {
fmt.Println("Detached HEAD state")
}

t, err := tag.GetTag(project.Repo, ref)
if err != nil {
return err
Expand Down
13 changes: 13 additions & 0 deletions forge/cli/pkg/tag/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import (
// point to the same commit, the first one found is returned.
func GetTag(repo *gg.Repository, ref *plumbing.Reference) (string, error) {
fmt.Println("Getting tags")
// Check if the HEAD is detached
if ref.Name() == plumbing.HEAD {
fmt.Println("Detached HEAD state")

tobj, err := repo.TagObject(ref.Hash())
if err != nil {
fmt.Println("Failed to get tag object")
return "", fmt.Errorf("failed to get tag object: %w", err)
}

return tobj.Name, nil
}

tags, err := repo.Tags()
if err != nil {
return "", fmt.Errorf("failed to get tags: %w", err)
Expand Down

0 comments on commit 4271ef7

Please sign in to comment.