1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
diff --git a/Makefile b/Makefile
index 8062c9714986917214946acc448fe7c84457586f..5a10f0b6f76fcf29aa0f38681b6686c4c95e9a21 100644
--- a/Makefile
+++ b/Makefile
@@ -13,3 +13,7 @@ -build.cmd="make gogit" \
-build.bin="./gogit" \
-build.exclude_regex="(themes/|repos/|Makefile)" \
-screen.clear_on_rebuild=true
+
+.PHONY: lint
+lint:
+ $(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run ./...
diff --git a/internal/repo-monitor/repo.go b/internal/repo-monitor/repo.go
index 264f2db0d1159112f4fbca6d8ff3402ae7702af5..2a8bd8a78f77653d43badd6e15c39dd3a157d51a 100644
--- a/internal/repo-monitor/repo.go
+++ b/internal/repo-monitor/repo.go
@@ -13,7 +13,7 @@
func ListRepos(paths string) []*types.Repo {
var repos []*types.Repo
slog.Debug("scanning for repositories", "path", paths)
- filepath.Walk(paths, func(path string, info os.FileInfo, err error) error {
+ err := filepath.Walk(paths, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
@@ -39,6 +39,9 @@ repos = append(repos, r)
return filepath.SkipDir
})
+ if err != nil {
+ slog.Warn("failed to list repositories", "error", err)
+ }
return repos
}
diff --git a/internal/repo-monitor/watch.go b/internal/repo-monitor/watch.go
index 860c1571c90c20983b90fd5a2c43edc6a368a42d..e8290229aabc6543911d36518ea1b02796dfd089 100644
--- a/internal/repo-monitor/watch.go
+++ b/internal/repo-monitor/watch.go
@@ -12,7 +12,11 @@ func PushUpdates(paths string, update func([]*types.Repo)) {
update(ListRepos(paths))
for {
c := make(chan notify.EventInfo, 1)
- notify.Watch(path.Join(paths, "..."), c, notify.All)
+ err := notify.Watch(path.Join(paths, "..."), c, notify.All)
+ if err != nil {
+ slog.Error("failed to watch for file changes. Live updates disabled.", "error", err)
+ return
+ }
ev := <-c
slog.Info("file change detected", "event", ev)
diff --git a/internal/types/repo.go b/internal/types/repo.go
index fdee205ad86b37986655b5385cfc8d0c8ce8a103..3782f4246830c444c36d92453f8e8f404c5870a1 100644
--- a/internal/types/repo.go
+++ b/internal/types/repo.go
@@ -58,7 +58,7 @@ return nil
}
result = append(result, head)
- branches.ForEach(func(ref *plumbing.Reference) error {
+ _ = branches.ForEach(func(ref *plumbing.Reference) error {
if ref.Name().String() == head.Name().String() {
return nil
}
@@ -84,7 +84,7 @@ return nil
}
var result []*plumbing.Reference
- tags.ForEach(func(ref *plumbing.Reference) error {
+ _ = tags.ForEach(func(ref *plumbing.Reference) error {
result = append(result, ref)
return nil
})
diff --git a/main.go b/main.go
index 1815bca2bf9b03e5d8b665ff2b6d3ce04b7bc5f9..4bcbeea8a79608a775fce115f246ea54e6411755 100644
--- a/main.go
+++ b/main.go
@@ -82,7 +82,10 @@ slog.Info("shutting down", "signal", sig)
shutdownComplete := make(chan struct{})
go func() {
- srv.Shutdown(context.Background())
+ err := srv.Shutdown(context.Background())
+ if err != nil {
+ slog.Error("failed to shutdown server", "error", err)
+ }
close(shutdownComplete)
}()
|