2018-07-17 20:28:37 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2018-08-13 19:32:11 +03:00
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-07-19 13:30:25 +03:00
|
|
|
"github.com/spf13/cobra"
|
2018-07-17 20:28:37 +03:00
|
|
|
)
|
|
|
|
|
2018-09-16 15:29:14 +03:00
|
|
|
func runStatusOpen(cmd *cobra.Command, args []string) error {
|
2018-07-17 20:28:37 +03:00
|
|
|
if len(args) > 1 {
|
|
|
|
return errors.New("Only opening one bug at a time is supported")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
return errors.New("You must provide a bug id")
|
|
|
|
}
|
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
backend, err := cache.NewRepoCache(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer backend.Close()
|
|
|
|
|
2018-07-17 20:28:37 +03:00
|
|
|
prefix := args[0]
|
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
b, err := backend.ResolveBugPrefix(prefix)
|
2018-07-17 20:28:37 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
err = b.Open()
|
2018-07-18 01:16:06 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-08-31 14:18:03 +03:00
|
|
|
return b.Commit()
|
2018-07-17 20:28:37 +03:00
|
|
|
}
|
|
|
|
|
2018-07-19 13:30:25 +03:00
|
|
|
var openCmd = &cobra.Command{
|
|
|
|
Use: "open <id>",
|
|
|
|
Short: "Mark the bug as open",
|
2018-09-16 15:29:14 +03:00
|
|
|
RunE: runStatusOpen,
|
2018-07-19 13:30:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2018-09-16 15:29:14 +03:00
|
|
|
statusCmd.AddCommand(openCmd)
|
2018-07-17 20:28:37 +03:00
|
|
|
}
|