~edwargix/git.sr.ht

85fb9eca26afe4f6b8e72faa7cf4c1b04a8ee5d6 — Drew DeVault 6 years ago 998c6a7
Improve logging in SSH pipeline
M gitsrht-keys/main.go => gitsrht-keys/main.go +1 -0
@@ 209,6 209,7 @@ func main() {
	}

	push := uuid.New()
	logger.Printf("Assigned uuid %s to this push", push.String())
	shellCommand := fmt.Sprintf("%s '%d' '%s' '%s'",
		shell, userId, username, b64key)
	fmt.Printf(`restrict,command="%s",`+

M gitsrht-shell/main.go => gitsrht-shell/main.go +4 -0
@@ 108,6 108,10 @@ func main() {
		cmdstr = ""
	}

	if pushUuid, ok := os.LookupEnv("SRHT_PUSH"); ok {
		logger.Printf("Running shell for push %s", pushUuid)
	}

	// Grab the command the user is trying to execute
	cmd, err = shlex.Split(cmdstr)
	if err != nil {

M gitsrht-update-hook/post-update.go => gitsrht-update-hook/post-update.go +2 -0
@@ 269,5 269,7 @@ func postUpdate() {
	// blocking the pusher's terminal.
	stage3 := exec.Command(hook, string(deliveriesJson), string(payloadBytes))
	stage3.Args[0] = "stage-3"
	logger.Printf("Executing stage 3 to record %d sync deliveries and make " +
		"%d async deliveries", len(deliveries), len(dbinfo.AsyncWebhooks))
	stage3.Start()
}

M gitsrht-update-hook/webhooks.go => gitsrht-update-hook/webhooks.go +3 -0
@@ 134,6 134,8 @@ func deliverWebhooks(subs []WebhookSubscription,
			continue
		}
		log.Println(runewidth.Truncate(string(respBody), 1024, "..."))
		logger.Printf("Delivered webhook to %s (sub %d), got %d",
			sub.Url, sub.Id, resp.StatusCode)

		var responseHeaders bytes.Buffer
		for name, values := range resp.Header {


@@ 141,6 143,7 @@ func deliverWebhooks(subs []WebhookSubscription,
				name, strings.Join(values, ", ")))
		}

		delivery.ResponseStatus = resp.StatusCode
		delivery.ResponseHeaders = responseHeaders.String()
		delivery.Response = string(respBody)[:65535]
		deliveries = append(deliveries, delivery)