Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package jira
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// IsJiraExternalRef checks if an external_ref URL matches the configured Jira instance.
|
|
// It validates both the URL structure (/browse/PROJECT-123) and optionally the host.
|
|
func IsJiraExternalRef(externalRef, jiraURL string) bool {
|
|
// Must contain /browse/ pattern
|
|
if !strings.Contains(externalRef, "/browse/") {
|
|
return false
|
|
}
|
|
|
|
// If jiraURL is provided, validate the host matches
|
|
if jiraURL != "" {
|
|
jiraURL = strings.TrimSuffix(jiraURL, "/")
|
|
if !strings.HasPrefix(externalRef, jiraURL) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// ExtractJiraKey extracts the Jira issue key from an external_ref URL.
|
|
// For example, "https://company.atlassian.net/browse/PROJ-123" returns "PROJ-123".
|
|
func ExtractJiraKey(externalRef string) string {
|
|
idx := strings.LastIndex(externalRef, "/browse/")
|
|
if idx == -1 {
|
|
return ""
|
|
}
|
|
return externalRef[idx+len("/browse/"):]
|
|
}
|
|
|
|
// ParseTimestamp parses Jira's timestamp format into a time.Time.
|
|
// Jira uses ISO 8601 with timezone: 2024-01-15T10:30:00.000+0000 or 2024-01-15T10:30:00.000Z
|
|
func ParseTimestamp(ts string) (time.Time, error) {
|
|
if ts == "" {
|
|
return time.Time{}, fmt.Errorf("empty timestamp")
|
|
}
|
|
|
|
// Try common formats
|
|
formats := []string{
|
|
"2006-01-02T15:04:05.000-0700",
|
|
"2006-01-02T15:04:05.000Z",
|
|
"2006-01-02T15:04:05-0700",
|
|
"2006-01-02T15:04:05Z",
|
|
time.RFC3339,
|
|
time.RFC3339Nano,
|
|
}
|
|
|
|
for _, format := range formats {
|
|
if t, err := time.Parse(format, ts); err == nil {
|
|
return t, nil
|
|
}
|
|
}
|
|
|
|
return time.Time{}, fmt.Errorf("unrecognized timestamp format: %s", ts)
|
|
}
|