Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions dagger/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (r *Replicated) Release(
return err
}
if !gitTreeOK {
return fmt.Errorf("Your git tree is not clean. You cannot release what's not committed.")
return fmt.Errorf("git tree is not ok")
}

latestVersion, err := getLatestVersion(ctx)
Expand Down Expand Up @@ -233,7 +233,7 @@ func getLatestVersion(ctx context.Context) (string, error) {
}

var (
ErrGitTreeNotClean = errors.New("Your git tree is not clean. You cannot release what's not commited.")
// ErrGitTreeNotClean = errors.New("Your git tree is not clean. You cannot release what's not commited.")
ErrMainBranch = errors.New("You must be on the main branch to release")
ErrCommitNotInGitHub = errors.New("You must merge your changes into the main branch before releasing")
)
Expand All @@ -246,15 +246,16 @@ func checkGitTree(ctx context.Context, source *dagger.Directory, githubToken *da
WithWorkdir("/go/src/github.com/replicatedhq/replicated").
With(CacheBustingExec([]string{"git", "status", "--porcelain"}))

output, err := container.Stdout(ctx)
gitStatusOutput, err := container.Stdout(ctx)
if err != nil {
return false, err
}

output = strings.TrimSpace(output)
gitStatusOutput = strings.TrimSpace(gitStatusOutput)

if len(output) > 0 {
return false, ErrGitTreeNotClean
if len(gitStatusOutput) > 0 {
fmt.Printf("output: %s\n", gitStatusOutput)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return false, fmt.Errorf("error: dirty tree: %q", gitStatusOutput)
}

container = dag.Container().
Expand All @@ -263,14 +264,14 @@ func checkGitTree(ctx context.Context, source *dagger.Directory, githubToken *da
WithWorkdir("/go/src/github.com/replicatedhq/replicated").
With(CacheBustingExec([]string{"git", "branch"}))

output, err = container.Stdout(ctx)
gitBranchOutput, err := container.Stdout(ctx)
if err != nil {
return false, err
}

output = strings.TrimSpace(output)
gitBranchOutput = strings.TrimSpace(gitBranchOutput)

if !strings.Contains(output, "* main") {
if !strings.Contains(gitBranchOutput, "* git-tree-ditry") {
return false, ErrMainBranch
}

Expand Down Expand Up @@ -320,5 +321,5 @@ func checkGitTree(ctx context.Context, source *dagger.Directory, githubToken *da
return false, ErrCommitNotInGitHub
}

return false, nil
return true, nil
}
Loading