File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 55 "github.com/gorilla/mux"
66 "github.com/typomedia/gitti/app/git"
77 "github.com/typomedia/gitti/app/helper"
8- "github.com/typomedia/gitti/app/msg"
98 "net/http"
9+ "sort"
1010)
1111
1212func Branches (w http.ResponseWriter , r * http.Request ) {
@@ -32,11 +32,20 @@ func Branches(w http.ResponseWriter, r *http.Request) {
3232 }
3333 }
3434
35- //json.NewEncoder(w).Encode(branches)
36- jsonData , err := json .Marshal (branches )
37- msg .Check (err )
35+ // sort branches by name
36+ branches .SortByName ()
37+
38+ //jsonData, err := json.Marshal(branches)
39+ //msg.Check(err)
3840
3941 // set application/json header
4042 w .Header ().Set ("Content-Type" , "application/json" )
41- w .Write (jsonData )
43+ //w.Write(jsonData)
44+ json .NewEncoder (w ).Encode (branches )
45+ }
46+
47+ func (refs * Refs ) SortByName () {
48+ sort .Slice (refs .Branches , func (i , j int ) bool {
49+ return refs .Branches [i ].Name < refs .Branches [j ].Name
50+ })
4251}
You can’t perform that action at this time.
0 commit comments