feat(identity): created-content footer
This commit is contained in:
14
internal/identity/footer.go
Normal file
14
internal/identity/footer.go
Normal file
@@ -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
|
||||
}
|
||||
19
internal/identity/footer_test.go
Normal file
19
internal/identity/footer_test.go
Normal file
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user