Skip to content

Commit

Permalink
feat: add a visual cue that shows tasks have been skipped (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-paul-t authored Jan 23, 2023
1 parent 09a5443 commit 2d68a50
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 251 deletions.
12 changes: 2 additions & 10 deletions cmd/uplift/bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"io"

"github.com/gembaadvantage/uplift/internal/context"
"github.com/gembaadvantage/uplift/internal/middleware/logging"
"github.com/gembaadvantage/uplift/internal/middleware/skip"
"github.com/gembaadvantage/uplift/internal/semver"
"github.com/gembaadvantage/uplift/internal/task"
"github.com/gembaadvantage/uplift/internal/task/bump"
Expand Down Expand Up @@ -110,7 +108,7 @@ func bumpFiles(opts bumpOptions, out io.Writer) error {
return err
}

tsks := []task.Runner{
tasks := []task.Runner{
gitcheck.Task{},
before.Task{},
gpgimport.Task{},
Expand All @@ -123,13 +121,7 @@ func bumpFiles(opts bumpOptions, out io.Writer) error {
after.Task{},
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
}

return nil
return task.Execute(ctx, tasks)
}

func setupBumpContext(opts bumpOptions, out io.Writer) (*context.Context, error) {
Expand Down
22 changes: 4 additions & 18 deletions cmd/uplift/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (

"github.com/gembaadvantage/uplift/internal/context"
"github.com/gembaadvantage/uplift/internal/git"
"github.com/gembaadvantage/uplift/internal/middleware/logging"
"github.com/gembaadvantage/uplift/internal/middleware/skip"
"github.com/gembaadvantage/uplift/internal/task"
"github.com/gembaadvantage/uplift/internal/task/changelog"
"github.com/gembaadvantage/uplift/internal/task/gitcheck"
Expand Down Expand Up @@ -139,7 +137,7 @@ func writeChangelog(opts changelogOptions, out io.Writer) error {
return err
}

tsks := []task.Runner{
tasks := []task.Runner{
gitcheck.Task{},
before.Task{},
scm.Task{},
Expand All @@ -151,13 +149,7 @@ func writeChangelog(opts changelogOptions, out io.Writer) error {
after.Task{},
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
}

return nil
return task.Execute(ctx, tasks)
}

func writeChangelogDiff(opts changelogOptions, out io.Writer) error {
Expand All @@ -166,21 +158,15 @@ func writeChangelogDiff(opts changelogOptions, out io.Writer) error {
return err
}

tsks := []task.Runner{
tasks := []task.Runner{
gitcheck.Task{},
before.Task{},
scm.Task{},
changelog.Task{},
after.Task{},
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
}

return nil
return task.Execute(ctx, tasks)
}

func setupChangelogContext(opts changelogOptions, out io.Writer) (*context.Context, error) {
Expand Down
20 changes: 5 additions & 15 deletions cmd/uplift/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
"io"

"github.com/gembaadvantage/uplift/internal/context"
"github.com/gembaadvantage/uplift/internal/middleware/logging"
"github.com/gembaadvantage/uplift/internal/middleware/skip"
"github.com/gembaadvantage/uplift/internal/semver"
"github.com/gembaadvantage/uplift/internal/task"
"github.com/gembaadvantage/uplift/internal/task/bump"
Expand Down Expand Up @@ -146,7 +144,7 @@ func release(opts releaseOptions, out io.Writer) error {
return err
}

tsks := []task.Runner{
tasks := []task.Runner{
gitcheck.Task{},
before.Task{},
gpgimport.Task{},
Expand All @@ -167,13 +165,7 @@ func release(opts releaseOptions, out io.Writer) error {
after.Task{},
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
}

return nil
return task.Execute(ctx, tasks)
}

func setupReleaseContext(opts releaseOptions, out io.Writer) (*context.Context, error) {
Expand Down Expand Up @@ -235,14 +227,12 @@ func checkRelease(opts releaseOptions, out io.Writer) error {
return err
}

tsks := []task.Runner{
tasks := []task.Runner{
nextsemver.Task{},
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
if err := task.Execute(ctx, tasks); err != nil {
return err
}

if ctx.NoVersionChanged {
Expand Down
14 changes: 3 additions & 11 deletions cmd/uplift/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (

"github.com/gembaadvantage/uplift/internal/context"
"github.com/gembaadvantage/uplift/internal/git"
"github.com/gembaadvantage/uplift/internal/middleware/logging"
"github.com/gembaadvantage/uplift/internal/middleware/skip"
"github.com/gembaadvantage/uplift/internal/semver"
"github.com/gembaadvantage/uplift/internal/task"
"github.com/gembaadvantage/uplift/internal/task/fetchtag"
Expand Down Expand Up @@ -168,19 +166,13 @@ func tagRepo(opts tagOptions, out io.Writer) error {
return err
}

tsks := tagRepoPipeline
tasks := tagRepoPipeline

if ctx.PrintNextTag {
tsks = printNextTagPipeline
tasks = printNextTagPipeline
}

for _, tsk := range tsks {
if err := skip.Running(tsk.Skip, logging.Log(tsk.String(), tsk.Run))(ctx); err != nil {
return err
}
}

return nil
return task.Execute(ctx, tasks)
}

func setupTagContext(opts tagOptions, out io.Writer) (*context.Context, error) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/sync v0.1.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
30 changes: 0 additions & 30 deletions internal/middleware/action.go

This file was deleted.

55 changes: 0 additions & 55 deletions internal/middleware/logging/logging.go

This file was deleted.

45 changes: 0 additions & 45 deletions internal/middleware/skip/skip.go

This file was deleted.

52 changes: 0 additions & 52 deletions internal/middleware/skip/skip_test.go

This file was deleted.

Loading

0 comments on commit 2d68a50

Please sign in to comment.