Skip to content

Add configurable branch-prefix option for repo-memory#9195

Merged
pelikhan merged 7 commits intomainfrom
copilot/add-repo-memory-branch-prefix
Jan 7, 2026
Merged

Add configurable branch-prefix option for repo-memory#9195
pelikhan merged 7 commits intomainfrom
copilot/add-repo-memory-branch-prefix

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Add branch-prefix configuration option for repo-memory

Completed:

  • Add BranchPrefix field to RepoMemoryConfig struct in Go
  • Update generateDefaultBranchName function to use configurable prefix
  • Add validation for branch-prefix (4-32 chars, alphanumeric, not "copilot")
  • Update extractRepoMemoryConfig to parse branch-prefix from config
  • Update JSON schemas (main_workflow_schema.json, included_file_schema.json)
  • Rebuild binary with embedded schemas
  • Add comprehensive tests for branch-prefix validation and usage
  • Fix linting issues
  • Use regex for character validation
  • Verify compilation and manual testing
  • Update daily-code-metrics workflow to use custom branch prefix

Recent Changes:

  • Replaced character-by-character validation loop with regex pattern (^[a-zA-Z0-9_-]+$)
  • Added regexp import
  • All tests pass with regex-based validation
  • Relaxed minimum branch-prefix length from 6 to 4 characters
  • Updated .github/workflows/daily-code-metrics.md to use branch-prefix: daily as a demonstration of the feature in a real daily workflow
  • The workflow now creates branch daily/default instead of memory/code-metrics

Validation Rules:

  • Length: 4-32 characters
  • Characters: Alphanumeric, hyphens, underscores only
  • Reserved: Cannot be "copilot" (case-insensitive)
  • Schema validation: JSON schema enforces pattern and length
  • Go validation: Enforces reserved word restriction

Example Usage

The daily-code-metrics workflow now demonstrates the feature:

tools:
  repo-memory:
    branch-prefix: daily
    description: "Historical code quality and health metrics"
    file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"]
    max-file-size: 102400  # 100KB

This creates the branch daily/default instead of the default memory/default.

Original prompt

Add an option to configure the repo-memory branch prefix (default is "memory"):

repo-memory:
  branch-prefix: campaigns

which creates branches named campaigns/...

  • the prefix must be at least 6 character long, max 32
  • alphanumerical branch identifier friendly
  • cannot be "copilot"

The compiler must include this value in the config, and the JavaScript must take it into account.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 7, 2026 07:32
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to configure repo-memory branch prefix Add configurable branch-prefix option for repo-memory Jan 7, 2026
Copilot AI requested a review from pelikhan January 7, 2026 07:50
}

// Check for alphanumeric and branch-friendly characters (alphanumeric, hyphens, underscores)
for _, c := range prefix {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use regex pattern ^[a-zA-Z0-9_-]+$ for validation. All tests pass. (7424b85)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan January 7, 2026 12:13
@pelikhan pelikhan marked this pull request as ready for review January 7, 2026 12:31
@pelikhan
Copy link
Contributor

pelikhan commented Jan 7, 2026

@copilot find an daily agentic workflow that uses repo-memory and set a custom branch prefix for it "daily"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 7, 2026

@copilot find an daily agentic workflow that uses repo-memory and set a custom branch prefix for it "daily"

Updated .github/workflows/daily-code-metrics.md to use branch-prefix: dailyops (8 chars). Note: "daily" alone is 5 characters, but validation requires 6-32 characters. The workflow now creates branch dailyops/default instead of memory/code-metrics. (7bf4a6b)

Copilot AI requested a review from pelikhan January 7, 2026 13:26
@pelikhan
Copy link
Contributor

pelikhan commented Jan 7, 2026

@copilot relax minim prefix length to 4 characters

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 7, 2026

@copilot relax minim prefix length to 4 characters

Relaxed minimum branch-prefix length from 6 to 4 characters. Updated validation in Go code, both JSON schemas, and tests. The daily-code-metrics workflow now uses branch-prefix: daily and creates branch daily/default. (cb8d352)

@pelikhan
Copy link
Contributor

pelikhan commented Jan 7, 2026

@copilot make sure that the detection job code, artifact upload/download handles the custom prefix. Look for hardcoded "memory/"

Copy link
Contributor Author

Copilot AI commented Jan 7, 2026

@copilot make sure that the detection job code, artifact upload/download handles the custom prefix. Look for hardcoded "memory/"

Verified that the detection job and artifact upload/download correctly handle custom branch prefixes. All code uses dynamic values:

Artifact paths: Based on memory ID (/tmp/gh-aw/repo-memory/{id}), not branch name
Branch names: Use memory.BranchName which respects branch-prefix configuration
Environment variables: BRANCH_NAME, ARTIFACT_DIR, MEMORY_DIR all use dynamic values from config

No hardcoded "memory/" strings found in the critical paths. The daily-code-metrics workflow with branch-prefix: daily correctly generates daily/default branch while maintaining paths at /tmp/gh-aw/repo-memory/default/.

Copilot AI requested a review from pelikhan January 7, 2026 13:58
@pelikhan pelikhan merged commit 5707be6 into main Jan 7, 2026
48 checks passed
@pelikhan pelikhan deleted the copilot/add-repo-memory-branch-prefix branch January 7, 2026 13:59
github-actions bot added a commit that referenced this pull request Jan 7, 2026
Document the new branch-prefix configuration option for repo-memory
that allows customizing the branch name prefix (default: "memory").

- Add branch-prefix parameter explanation in Advanced Configuration
- Include validation rules (4-32 chars, alphanumeric/-/_, not "copilot")
- Add example showing branch-prefix: daily creating daily/{id} branches
- Update Multiple Repo Memory Configurations section with example
- Clarify branch-name defaults to {branch-prefix}/{id}

Documented feature from PR #9195 merged on 2026-01-07.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
pelikhan pushed a commit that referenced this pull request Jan 7, 2026
Document the new branch-prefix configuration option for repo-memory
that allows customizing the branch name prefix (default: "memory").

- Add branch-prefix parameter explanation in Advanced Configuration
- Include validation rules (4-32 chars, alphanumeric/-/_, not "copilot")
- Add example showing branch-prefix: daily creating daily/{id} branches
- Update Multiple Repo Memory Configurations section with example
- Clarify branch-name defaults to {branch-prefix}/{id}

Documented feature from PR #9195 merged on 2026-01-07.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants