2018-07-17 20:28:37 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2018-08-31 14:18:03 +03:00
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2018-09-18 14:28:01 +03:00
|
|
|
"github.com/MichaelMure/git-bug/commands/select"
|
2018-10-25 00:36:39 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/interrupt"
|
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 runStatusClose(cmd *cobra.Command, args []string) error {
|
2018-08-31 14:18:03 +03:00
|
|
|
backend, err := cache.NewRepoCache(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer backend.Close()
|
2018-10-25 00:36:39 +03:00
|
|
|
interrupt.RegisterCleaner(backend.Close)
|
2018-08-31 14:18:03 +03:00
|
|
|
|
2018-09-18 14:28:01 +03:00
|
|
|
b, args, err := _select.ResolveBug(backend, args)
|
2018-07-17 20:28:37 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-24 14:58:04 +03:00
|
|
|
_, err = b.Close()
|
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 closeCmd = &cobra.Command{
|
2018-10-17 21:38:10 +03:00
|
|
|
Use: "close [<id>]",
|
2019-02-24 16:46:08 +03:00
|
|
|
Short: "Mark a bug as closed.",
|
2019-12-08 23:15:06 +03:00
|
|
|
PreRunE: loadRepoEnsureUser,
|
2018-10-17 21:38:10 +03:00
|
|
|
RunE: runStatusClose,
|
2018-07-19 13:30:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2018-09-16 15:29:14 +03:00
|
|
|
statusCmd.AddCommand(closeCmd)
|
2018-07-17 20:28:37 +03:00
|
|
|
}
|