Skip to content

Make --allow replace an upstream's configured allow-list - #60

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/allow-replaces-config-list
Sep 29, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/allow-replaces-config-list

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #46

Problem

--allow was written as Repositories:{index} configuration keys. Configuration merges arrays by index, so when it was combined with --config a flag overwrote only the file's first entries. For example, a file with studio/game.git, studio/tools.git plus --allow github=studio/engine.git bound studio/engine.git, studio/tools.git. studio/game.git was dropped without any message.

Change

This implements the maintainer's decision on the issue (replace, not append), in the same way ktsu-dev/GitLfsCache#67 did for the sibling tool:

  • TryParseAllows groups the flags by upstream. It is case-insensitive and keeps the order the flags were typed in.
  • ReplaceAllowLists runs as a PostConfigure<GitBranchStateCacheOptions>. It sets each named upstream's Repositories to exactly the flag patterns. Upstreams that no flag names keep their configured list. An upstream that only a flag names is created.
  • The options validator still runs after post-configure, so flag patterns get the same validation as before.
  • The --allow help text and the README now describe the replace behaviour.

Tests

  • New GitBranchStateCache.Tests/Tool/AllowFlagTests.cs, with the test project now referencing the Tool project. It covers the acceptance case (N configured entries plus M flags gives exactly M), repeated flags, other upstreams left untouched, an unconfigured upstream, no flags at all, and malformed entries.
  • I checked that the tests catch the bug by temporarily swapping ReplaceAllowLists for the old merge-by-index behaviour. Allow_FewerPatternsThanConfigured_ReplacesTheConfiguredList failed, and it passes with the fix.
  • Full suite: 228/228 passed locally (dotnet test GitBranchStateCache.slnx).

🤖 Generated with Claude Code

https://claude.ai/code/session_015LsGhhi4Vq9pNq2fr5T75T


Generated by Claude Code

The --allow flags were written as Repositories:{index} configuration keys,
and configuration merges arrays by index. A flag therefore replaced only the
first entries of a list from --config, appsettings.json or the environment:
config ["studio/game.git", "studio/tools.git"] plus
--allow github=studio/engine.git bound ["studio/engine.git",
"studio/tools.git"], silently dropping studio/game.git.

The flags are now grouped per upstream and assigned in a post-configure step,
so an upstream named by --allow allows exactly the flag patterns. Upstreams no
flag names keep their configured list. This matches ktsu.GitLfsCache, and the
--allow help text and README now say so.

Fixes #46

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LsGhhi4Vq9pNq2fr5T75T
@sonarqubecloud

Copy link
Copy Markdown

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.

--allow combined with --config overwrites the config file's first allow-list entries instead of appending, silently dropping repositories

2 participants