Skip to content

Commit d03b3f2

Browse files
committed
Merged in release/0.10.2 (pull request #12)
Merge release/0.10.2
2 parents a8b2fc0 + 0b0ff4e commit d03b3f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+259
-220
lines changed

Makefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ all: test build; ## Test and Build the application
120120

121121
gendoc: __gendoc_init__ $(BIN_DIR)/$(PROJECT).pdf; @ ## Generate the PDF documentation
122122

123-
publish: __publish_init__ __publish_binaries__; @ ## Publish the binaries to the Repository
123+
publish: __publish_init__ __publish_binaries__ __publish_snap__; @ ## Publish the binaries to the Repository
124124

125-
archive: __archive_init__ __archive_all__ __archive_chocolatey__ __archive_debian__ __archive_rpm__ ; @ ## Archive the binaries
125+
archive: __archive_init__ __archive_all__ __archive_chocolatey__ __archive_debian__ __archive_rpm__ __archive_snap__ ; @ ## Archive the binaries
126126

127127
build: __build_init__ __build_all__; @ ## Build the application for all platforms
128128

@@ -211,7 +211,7 @@ __start__: stop $(BIN_DIR)/$(GOOS)/$(PROJECT) | $(TMP_DIR) $(LOG_DIR); $(info $(
211211
$Q DEBUG=1 LOG_DESTINATION="$(LOG_DIR)/$(PROJECT).log" $(BIN_DIR)/$(GOOS)/$(PROJECT) & echo $$! > $(TMP_DIR)/$(PROJECT).pid
212212

213213
# publish recipes
214-
.PHONY: __publish_init__ __publish_binaries__
214+
.PHONY: __publish_init__ __publish_binaries__ __publish_snap__
215215
__publish_init__:;
216216
__publish_binaries__: archive
217217
$(info $(M) Uploading the binary packages...)
@@ -223,6 +223,14 @@ __publish_binaries__: archive
223223
$(info $(M) Uploading the RPM packages...)
224224
$Q $(foreach archive, $(wildcard $(BIN_DIR)/*.rpm), go run . artifact upload --progress $(archive) ;)
225225

226+
__publish_snap__: \
227+
$(TMP_DIR)/__publish_snap__ \
228+
;
229+
230+
$(TMP_DIR)/__publish_snap__: $(TMP_DIR) __archive_snap__
231+
$Q snapcraft upload --release=latest/edge $(BIN_DIR)/$(PACKAGE)_$(VERSION)_amd64.snap
232+
$Q $(TOUCH)
233+
226234
# archive recipes
227235
.PHONY: __archive_init__ __archive_all__ __archive_chocolatey__ __archive_debian__ __archive_rpm__ __archive_snap__
228236
__archive_init__:; $(info $(M) Archiving binaries for application $(PROJECT))

cmd/artifact/delete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -56,7 +57,7 @@ func deleteProcess(cmd *cobra.Command, args []string) error {
5657

5758
var merr errors.MultiError
5859
for _, artifactName := range args {
59-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting artifact %s", artifactName) {
60+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting artifact %s", artifactName) {
6061
err := profile.Current.Delete(
6162
log.ToContext(cmd.Context()),
6263
cmd,

cmd/artifact/download.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -61,7 +62,7 @@ func getProcess(cmd *cobra.Command, args []string) error {
6162

6263
var merr errors.MultiError
6364
for _, artifactName := range args {
64-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Downloading artifact %s to %s", artifactName, downloadOptions.Destination) {
65+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Downloading artifact %s to %s", artifactName, downloadOptions.Destination) {
6566
err := profile.Current.Download(
6667
log.ToContext(cmd.Context()),
6768
cmd,

cmd/artifact/upload.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -46,7 +47,7 @@ func uploadProcess(cmd *cobra.Command, args []string) error {
4647

4748
var merr errors.MultiError
4849
for _, artifactName := range args {
49-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Uploading artifact %s to %s", artifactName, downloadOptions.Destination) {
50+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Uploading artifact %s to %s", artifactName, downloadOptions.Destination) {
5051
err := profile.Current.Upload(
5152
log.ToContext(cmd.Context()),
5253
cmd,

cmd/common/whatif.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package common
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
"github.com/gildas/go-logger"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
// WhatIf prints what would be done by the command
13+
//
14+
// # If the DryRun flag is set, it prints what would be done by the command and tells the caller to not proceed
15+
//
16+
// otherwise it does nothing
17+
func WhatIf(context context.Context, cmd *cobra.Command, format string, args ...any) (proceed bool) {
18+
if cmd.Flag("dry-run").Changed {
19+
logger.Must(logger.FromContext(context)).Infof("Dry run: "+format, args...)
20+
fmt.Fprintf(os.Stderr, "Dry run: "+format+"\n", args...)
21+
return false
22+
}
23+
return true
24+
}

cmd/issue/attachment/delete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-flags"
@@ -62,7 +63,7 @@ func deleteProcess(cmd *cobra.Command, args []string) error {
6263

6364
var merr errors.MultiError
6465
for _, attachmentID := range args {
65-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting attachment %s from issue %s", attachmentID, deleteOptions.IssueID) {
66+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting attachment %s from issue %s", attachmentID, deleteOptions.IssueID) {
6667
err := profile.Current.Delete(
6768
log.ToContext(cmd.Context()),
6869
cmd,

cmd/issue/attachment/download.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-flags"
@@ -58,7 +59,7 @@ func downloadProcess(cmd *cobra.Command, args []string) error {
5859
return errors.ArgumentMissing.With("profile")
5960
}
6061

61-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Downloading attachment %s from issue %s to %s", args[0], downloadOptions.IssueID, downloadOptions.Destination) {
62+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Downloading attachment %s from issue %s to %s", args[0], downloadOptions.IssueID, downloadOptions.Destination) {
6263
err := profile.Current.Download(
6364
log.ToContext(cmd.Context()),
6465
cmd,

cmd/issue/attachment/upload.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-flags"
@@ -43,7 +44,7 @@ func uploadProcess(cmd *cobra.Command, args []string) error {
4344
return errors.ArgumentMissing.With("profile")
4445
}
4546

46-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Uploading attachment %s to issue %s", args[0], uploadOptions.IssueID) {
47+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Uploading attachment %s to issue %s", args[0], uploadOptions.IssueID) {
4748
err := profile.Current.Upload(
4849
log.ToContext(cmd.Context()),
4950
cmd,

cmd/issue/comment/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func createProcess(cmd *cobra.Command, args []string) (err error) {
5757
}
5858

5959
log.Record("payload", payload).Infof("Creating issue comment")
60-
if !profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating comment for issue %s", createOptions.IssueID) {
60+
if !common.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating comment for issue %s", createOptions.IssueID) {
6161
return nil
6262
}
6363
var comment Comment

cmd/issue/comment/delete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-flags"
@@ -61,7 +62,7 @@ func deleteProcess(cmd *cobra.Command, args []string) error {
6162

6263
var merr errors.MultiError
6364
for _, commentID := range args {
64-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting comment %s from issue %s", commentID, deleteOptions.IssueID) {
65+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting comment %s from issue %s", commentID, deleteOptions.IssueID) {
6566
err := profile.Current.Delete(
6667
log.ToContext(cmd.Context()),
6768
cmd,

cmd/issue/comment/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func updateProcess(cmd *cobra.Command, args []string) (err error) {
6969
}
7070

7171
log.Record("payload", payload).Infof("Updating issue comment")
72-
if !profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating comment %s for issue %s", updateOptions.Comment, updateOptions.IssueID) {
72+
if !common.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating comment %s for issue %s", updateOptions.Comment, updateOptions.IssueID) {
7373
return nil
7474
}
7575
var comment Comment

cmd/issue/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func createProcess(cmd *cobra.Command, args []string) (err error) {
9090
}
9191

9292
log.Record("payload", payload).Infof("Creating issue")
93-
if !profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating issue") {
93+
if !common.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating issue") {
9494
return nil
9595
}
9696
var issue Issue

cmd/issue/delete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -56,7 +57,7 @@ func deleteProcess(cmd *cobra.Command, args []string) error {
5657

5758
var merr errors.MultiError
5859
for _, issueID := range args {
59-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting issue %s", issueID) {
60+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting issue %s", issueID) {
6061
err := profile.Current.Delete(
6162
log.ToContext(cmd.Context()),
6263
cmd,

cmd/issue/unvote.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -46,7 +47,7 @@ func unvoteProcess(cmd *cobra.Command, args []string) (err error) {
4647
return errors.ArgumentMissing.With("profile")
4748
}
4849

49-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Unvoting from issue %s", args[0]) {
50+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Unvoting from issue %s", args[0]) {
5051
err = profile.Current.Delete(
5152
log.ToContext(cmd.Context()),
5253
cmd,

cmd/issue/unwatch.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -46,7 +47,7 @@ func unwatchProcess(cmd *cobra.Command, args []string) (err error) {
4647
return errors.ArgumentMissing.With("profile")
4748
}
4849

49-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Unwatching issue %s", args[0]) {
50+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Unwatching issue %s", args[0]) {
5051
err = profile.Current.Delete(
5152
log.ToContext(cmd.Context()),
5253
cmd,

cmd/issue/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func updateProcess(cmd *cobra.Command, args []string) (err error) {
108108
log.Record("payload", payload).Infof("Updating issue %s", args[0])
109109
var issue Issue
110110

111-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating issue %s", args[0]) {
111+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating issue %s", args[0]) {
112112
err = profile.Current.Put(
113113
log.ToContext(cmd.Context()),
114114
cmd,

cmd/issue/vote.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -46,7 +47,7 @@ func voteProcess(cmd *cobra.Command, args []string) (err error) {
4647
return errors.ArgumentMissing.With("profile")
4748
}
4849

49-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Voting for issue %s", args[0]) {
50+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Voting for issue %s", args[0]) {
5051
err = profile.Current.Put(
5152
log.ToContext(cmd.Context()),
5253
cmd,

cmd/issue/watch.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"bitbucket.org/gildas_cherruel/bb/cmd/profile"
89
"github.com/gildas/go-errors"
910
"github.com/gildas/go-logger"
@@ -58,7 +59,7 @@ func watchProcess(cmd *cobra.Command, args []string) (err error) {
5859
return
5960
}
6061

61-
if profile.Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Watching issue %s", args[0]) {
62+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Watching issue %s", args[0]) {
6263
err = profile.Current.Put(
6364
log.ToContext(cmd.Context()),
6465
cmd,

cmd/profile/create.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55
"path/filepath"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"github.com/gildas/go-errors"
89
"github.com/gildas/go-flags"
910
"github.com/gildas/go-logger"
@@ -73,7 +74,7 @@ func createProcess(cmd *cobra.Command, args []string) error {
7374
return errors.DuplicateFound.With("name", createOptions.Name)
7475
}
7576

76-
if !Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating profile %s", createOptions.Name) {
77+
if !common.WhatIf(log.ToContext(cmd.Context()), cmd, "Creating profile %s", createOptions.Name) {
7778
return nil
7879
}
7980
Profiles.Add(&createOptions.Profile)

cmd/profile/delete.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package profile
33
import (
44
"strings"
55

6+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
67
"github.com/gildas/go-logger"
78
"github.com/spf13/cobra"
89
"github.com/spf13/viper"
@@ -40,11 +41,11 @@ func deleteProcess(cmd *cobra.Command, args []string) (err error) {
4041

4142
if deleteOptions.All {
4243
log.Infof("Deleting all profiles")
43-
if Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting all profiles") {
44+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting all profiles") {
4445
deleted = Profiles.Delete(Profiles.Names()...)
4546
}
4647
} else {
47-
if Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting profiles %s", strings.Join(args, ", ")) {
48+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Deleting profiles %s", strings.Join(args, ", ")) {
4849
deleted = Profiles.Delete(args...)
4950
}
5051
}

cmd/profile/profile.go

-13
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,6 @@ func (profile Profile) Print(context context.Context, cmd *cobra.Command, payloa
287287
return nil
288288
}
289289

290-
// WhatIf prints what would be done by the command
291-
//
292-
// If the DryRun flag is set, it prints what would be done by the command
293-
// otherwise it does nothing
294-
func (profile Profile) WhatIf(context context.Context, cmd *cobra.Command, format string, args ...any) (proceed bool) {
295-
if cmd.Flag("dry-run").Changed {
296-
logger.Must(logger.FromContext(context)).Infof("Dry run: "+format, args...)
297-
fmt.Fprintf(os.Stderr, "Dry run: "+format+"\n", args...)
298-
return false
299-
}
300-
return true
301-
}
302-
303290
// MarshalJSON marshals this profile to JSON
304291
//
305292
// implements json.Marshaler

cmd/profile/update.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55
"path/filepath"
66

7+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
78
"github.com/gildas/go-errors"
89
"github.com/gildas/go-flags"
910
"github.com/gildas/go-logger"
@@ -74,7 +75,7 @@ func updateProcess(cmd *cobra.Command, args []string) error {
7475
}
7576

7677
log.Record("profile", profile).Debugf("Updating profile %s", profile.Name)
77-
if !Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating profile %s", profile.Name) {
78+
if !common.WhatIf(log.ToContext(cmd.Context()), cmd, "Updating profile %s", profile.Name) {
7879
return nil
7980
}
8081
err := profile.Update(updateOptions.Profile)

cmd/profile/use.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package profile
22

33
import (
4+
"bitbucket.org/gildas_cherruel/bb/cmd/common"
45
"github.com/gildas/go-errors"
56
"github.com/gildas/go-logger"
67
"github.com/spf13/cobra"
@@ -28,7 +29,7 @@ func useProcess(cmd *cobra.Command, args []string) error {
2829
if !found {
2930
return errors.NotFound.With("profile", args[0])
3031
}
31-
if Current.WhatIf(log.ToContext(cmd.Context()), cmd, "Using profile %s as default", args[0]) {
32+
if common.WhatIf(log.ToContext(cmd.Context()), cmd, "Using profile %s as default", args[0]) {
3233
Profiles.SetCurrent(profile.Name)
3334
viper.Set("profiles", Profiles)
3435
return viper.WriteConfig()

0 commit comments

Comments
 (0)