Sort hooks by both name and projectName
Sorting hooks by both Name and ProjectName as hook name can be same
between projects.
Change-Id: Ic3af8abdf035fb9d9e059be277032f03fdd7c281
diff --git a/project/project.go b/project/project.go
index 7295977..7d9f50a 100644
--- a/project/project.go
+++ b/project/project.go
@@ -274,7 +274,7 @@
}
// HooksByName implements the Sort interface. It sorts Hooks by the Name
-// field.
+// and ProjectName field.
type HooksByName []Hook
func (hooks HooksByName) Len() int {
@@ -284,6 +284,9 @@
hooks[i], hooks[j] = hooks[j], hooks[i]
}
func (hooks HooksByName) Less(i, j int) bool {
+ if hooks[i].Name == hooks[j].Name {
+ return hooks[i].ProjectName < hooks[j].ProjectName
+ }
return hooks[i].Name < hooks[j].Name
}