commands: fix a panic on merge invalid

Michael Muré created

Change summary

bug/bug.go       | 6 +++++-
commands/pull.go | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)

Detailed changes

bug/bug.go 🔗

@@ -576,8 +576,12 @@ func (bug *Bug) Id() string {
 
 // HumanId return the Bug identifier truncated for human consumption
 func (bug *Bug) HumanId() string {
+	return FormatHumanID(bug.Id())
+}
+
+func FormatHumanID(id string) string {
 	format := fmt.Sprintf("%%.%ds", humanIdLength)
-	return fmt.Sprintf(format, bug.Id())
+	return fmt.Sprintf(format, id)
 }
 
 // CreateLamportTime return the Lamport time of creation

commands/pull.go 🔗

@@ -42,7 +42,7 @@ func runPull(cmd *cobra.Command, args []string) error {
 		}
 
 		if merge.Status != bug.MergeStatusNothing {
-			fmt.Printf("%s: %s\n", merge.Bug.HumanId(), merge)
+			fmt.Printf("%s: %s\n", bug.FormatHumanID(merge.Id), merge)
 		}
 	}