···
···
Usage: "internal API endpoint",
Value: "http://localhost:5444",
50
+
Usage: "path to message of the day file",
51
+
Value: "/home/git/motd",
···
gitDir := cmd.String("git-dir")
logPath := cmd.String("log-path")
endpoint := cmd.String("internal-api")
64
+
motdFile := cmd.String("motd-file")
logFile, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
···
152
-
if gitCommand == "git-upload-pack" {
153
-
fmt.Fprintf(os.Stderr, "\x02%s\n", "Welcome to this knot!")
160
+
var motdReader io.Reader
161
+
if reader, err := os.Open(motdFile); err != nil {
162
+
if !errors.Is(err, os.ErrNotExist) {
163
+
l.Error("failed to read motd file", "error", err)
165
+
motdReader = strings.NewReader("Welcome to this knot!\n")
155
-
fmt.Fprintf(os.Stderr, "%s\n", "Welcome to this knot!")
167
+
motdReader = reader
169
+
if gitCommand == "git-upload-pack" {
170
+
io.WriteString(os.Stderr, "\x02")
172
+
io.Copy(os.Stderr, motdReader)
gitCmd := exec.Command(gitCommand, fullPath)
gitCmd.Stdout = os.Stdout