diff options
author | Michael Muré <batolettre@gmail.com> | 2019-03-01 23:17:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-01 23:17:57 +0100 |
commit | 7260ca05bc3588c0572887a7d8f1b897c7fc13da (patch) | |
tree | 66854358df3cb9de651f7688556ec5a4b8ab1868 /commands/root.go | |
parent | 0aefae6fcca5786f2c898029c3d6282f760f2c63 (diff) | |
parent | b6bed784e5664819250aac20b2b9690879ee6ab1 (diff) | |
download | git-bug-7260ca05bc3588c0572887a7d8f1b897c7fc13da.tar.gz |
Merge pull request #89 from MichaelMure/identity
WIP identity in git
Diffstat (limited to 'commands/root.go')
-rw-r--r-- | commands/root.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/commands/root.go b/commands/root.go index 797ae949..adbf51d9 100644 --- a/commands/root.go +++ b/commands/root.go @@ -6,6 +6,7 @@ import ( "os" "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/spf13/cobra" ) @@ -18,7 +19,7 @@ var repo repository.ClockedRepo // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ Use: rootCommandName, - Short: "A bug tracker embedded in Git", + Short: "A bug tracker embedded in Git.", Long: `git-bug is a bug tracker embedded in git. git-bug use git objects to store the bug tracking separated from the files @@ -53,6 +54,7 @@ func Execute() { } } +// loadRepo is a pre-run function that load the repository for use in a command func loadRepo(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { @@ -70,3 +72,24 @@ func loadRepo(cmd *cobra.Command, args []string) error { return nil } + +// loadRepoEnsureUser is the same as loadRepo, but also ensure that the user has configured +// an identity. Use this pre-run function when an error after using the configured user won't +// do. +func loadRepoEnsureUser(cmd *cobra.Command, args []string) error { + err := loadRepo(cmd, args) + if err != nil { + return err + } + + set, err := identity.IsUserIdentitySet(repo) + if err != nil { + return err + } + + if !set { + return identity.ErrNoIdentitySet + } + + return nil +} |