From 3613c36afb746592846a9b5f5c622d05a537c596 Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Mon, 4 May 2026 21:05:42 +0200 Subject: [PATCH] feat(identity): created-content footer --- internal/identity/footer.go | 14 ++++++++++++++ internal/identity/footer_test.go | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 internal/identity/footer.go create mode 100644 internal/identity/footer_test.go diff --git a/internal/identity/footer.go b/internal/identity/footer.go new file mode 100644 index 0000000..a57dc9e --- /dev/null +++ b/internal/identity/footer.go @@ -0,0 +1,14 @@ +package identity + +import "strings" + +func ApplyFooter(body, caller string) string { + if caller == "" { + return body + } + footer := "\n\n---\n_Created via git-mcp on behalf of @" + caller + "_" + if strings.HasSuffix(body, footer) { + return body + } + return body + footer +} diff --git a/internal/identity/footer_test.go b/internal/identity/footer_test.go new file mode 100644 index 0000000..e30aa8e --- /dev/null +++ b/internal/identity/footer_test.go @@ -0,0 +1,19 @@ +package identity_test + +import ( + "testing" + + "gitea.d-ma.be/mathias/gitea-mcp/internal/identity" + "github.com/stretchr/testify/assert" +) + +func TestApplyFooterAppendsWhenCallerSet(t *testing.T) { + body := identity.ApplyFooter("Initial body.", "mathiasbq") + assert.Contains(t, body, "Initial body.") + assert.Contains(t, body, "_Created via git-mcp on behalf of @mathiasbq_") +} + +func TestApplyFooterUnchangedWhenCallerEmpty(t *testing.T) { + body := identity.ApplyFooter("Initial body.", "") + assert.Equal(t, "Initial body.", body) +}