Skip to content

Commit 6e00c07

Browse files
committed
sort repos by name
1 parent 00de6e9 commit 6e00c07

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Application struct {
1313

1414
var App = Application{
1515
Name: "gitti",
16-
Version: "0.1.1",
16+
Version: "0.1.2",
1717
Author: "Philipp Speck <[email protected]>",
1818
Description: "Git HTTP Daemon",
1919
Explanation: "Git HTTP Daemon for managing multiple repositories via web hooks.",

app/hdlr/log.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ func Log(w http.ResponseWriter, r *http.Request) {
1818
_, commit := git.Log(repo.Path)
1919

2020
fmt.Fprintf(w, "%v\n", commit)
21-
2221
}

app/helper/repo.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package helper
22

33
import (
44
"github.com/spf13/viper"
5+
"sort"
56
)
67

78
type Repos struct {
@@ -26,21 +27,26 @@ func GetRepos() Repos {
2627

2728
}
2829

30+
// Sort the repos by name
31+
sort.Slice(repositories.Repos[:], func(i, j int) bool {
32+
return repositories.Repos[i].Name < repositories.Repos[j].Name
33+
})
34+
2935
return repositories
3036
}
3137

3238
func GetRepo(project string) Repo {
33-
repo := Repo{}
39+
repository := Repo{}
3440
repos := GetRepos()
3541

3642
for _, repo := range repos.Repos {
3743
if repo.Name == project {
38-
repo = Repo{
44+
repository = Repo{
3945
Name: repo.Name,
4046
Path: repo.Path,
4147
}
4248
}
4349
}
4450

45-
return repo
51+
return repository
4652
}

0 commit comments

Comments
 (0)