Skip to content

Commit

Permalink
Move git helper to own package
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Apr 28, 2024
1 parent a1b23c0 commit 0b0718d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/speculative/git.go → pkg/git/git.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package speculative
package git

import (
"errors"
Expand All @@ -9,7 +9,7 @@ import (
giturls "github.com/whilp/git-urls"
)

func gitRepoOrigin() (*url.URL, error) {
func RepoOrigin() (*url.URL, error) {
cwd, err := os.Getwd()
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/speculative/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/cenkalti/backoff"
"github.com/google/go-github/v61/github"
"github.com/nimbolus/terraform-backend/pkg/git"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -37,7 +38,7 @@ func NewCommand() *cobra.Command {

func run(ctx context.Context) error {
if owner == "" || repo == "" {
if ghURL, err := gitRepoOrigin(); err == nil {
if ghURL, err := git.RepoOrigin(); err == nil {
parts := strings.Split(ghURL.Path, "/")
if len(parts) >= 2 {
owner = parts[0]
Expand Down

0 comments on commit 0b0718d

Please sign in to comment.