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) +}