Skip to content

Commit bdc0413

Browse files
authored
servegit: use error hook (#1037)
Before this if the git command failed we would nil panic since the Logger on gitservice.Handler was not set. This commit updates us to the latest version of lib which instead takes in an error hook so we can use the attached stdlib logger. Test Plan: go test
1 parent 998d087 commit bdc0413

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

deps.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,8 +1875,8 @@ def go_dependencies():
18751875
name = "com_github_sourcegraph_sourcegraph_lib",
18761876
build_file_proto_mode = "disable_global",
18771877
importpath = "github.com/sourcegraph/sourcegraph/lib",
1878-
sum = "h1:NJyyvyYU/DNZmNFui8ktnHke3hS/PYLmDUbWNHSHKuQ=",
1879-
version = "v0.0.0-20230316093010-26299ec302d0",
1878+
sum = "h1:0hAo7bbfcF3uujbq2eNl2DpN6zUrjacWAK3iSan5Q0k=",
1879+
version = "v0.0.0-20230914103605-e3a8bc516ddc",
18801880
)
18811881
go_repository(
18821882
name = "com_github_spf13_afero",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/sourcegraph/go-diff v0.6.2-0.20221123165719-f8cd299c40f3
3131
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf
3232
github.com/sourcegraph/scip v0.3.1-0.20230627154934-45df7f6d33fc
33-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230822113036-acc34d9b2e95
33+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230914103605-e3a8bc516ddc
3434
github.com/stretchr/testify v1.8.4
3535
golang.org/x/net v0.12.0
3636
golang.org/x/sync v0.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ github.com/sourcegraph/log v0.0.0-20230711093019-40c57b632cca h1:VwYrG1+YNyOD3nS
425425
github.com/sourcegraph/log v0.0.0-20230711093019-40c57b632cca/go.mod h1:IDp09QkoqS8Z3CyN2RW6vXjgABkNpDbyjLIHNQwQ8P8=
426426
github.com/sourcegraph/scip v0.3.1-0.20230627154934-45df7f6d33fc h1:o+eq0cjVV3B5ngIBF04Lv3GwttKOuYFF5NTcfXWXzfA=
427427
github.com/sourcegraph/scip v0.3.1-0.20230627154934-45df7f6d33fc/go.mod h1:7ZKAtLIUmiMvOIgG5LMcBxdtBXVa0v2GWC4Hm1ASYQ0=
428-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230822113036-acc34d9b2e95 h1:xkoH/Vn4HMAga75N1YgTdv8nhjCXtbkw0BLY7+M3oyk=
429-
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230822113036-acc34d9b2e95/go.mod h1:hhrNfT3eDxsAsjaWEn8vWjmrEFDa9v238tDf9TyEAHc=
428+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230914103605-e3a8bc516ddc h1:0hAo7bbfcF3uujbq2eNl2DpN6zUrjacWAK3iSan5Q0k=
429+
github.com/sourcegraph/sourcegraph/lib v0.0.0-20230914103605-e3a8bc516ddc/go.mod h1:r5UrJ7GztZRFu/LlF5lNS5XzAsnYdGphS4CJEm4Lnts=
430430
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o=
431431
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
432432
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=

internal/servegit/serve.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func (s *Serve) handler() http.Handler {
106106
Dir: func(name string) string {
107107
return filepath.Join(s.Root, filepath.FromSlash(name))
108108
},
109+
ErrorHook: func(err error, stderr string) {
110+
s.Info.Printf("git-service error: %s\nstderr:\n%s", err.Error(), stderr)
111+
},
109112
Trace: func(ctx context.Context, svc, repo, protocol string) func(error) {
110113
start := time.Now()
111114
return func(err error) {

0 commit comments

Comments
 (0)