Skip to content

Commit a69b765

Browse files
feat: add --get-url flag to git ls-remote for URL config overrides
Closes #1097 Co-authored-by: marcossevilla <marcossevilla@users.noreply.github.com>
1 parent 20a3943 commit a69b765

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/src/cli/git_cli.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ Make sure the remote exists and you have the correct access rights.''';
2121
/// Git CLI
2222
class Git {
2323
/// Determine whether the [remote] is reachable.
24+
///
25+
/// The check honors `url.<base>.insteadOf` git config overrides by passing
26+
/// `--get-url` to `git ls-remote`, mirroring how the actual pull would
27+
/// resolve the remote.
2428
static Future<void> reachable(Uri remote, {required Logger logger}) async {
2529
try {
2630
await _Cmd.run('git', [
2731
'ls-remote',
32+
'--get-url',
2833
'$remote',
2934
'--exit-code',
3035
], logger: logger);

test/src/cli/git_cli_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ void main() {
6464
}, runProcess: process.run);
6565
});
6666

67+
test('passes --get-url to respect insteadOf overrides', () async {
68+
final remote = Uri.parse('https://github.com/org/repo');
69+
await ProcessOverrides.runZoned(() async {
70+
await Git.reachable(remote, logger: logger);
71+
}, runProcess: process.run);
72+
73+
verify(
74+
() => process.run(
75+
'git',
76+
['ls-remote', '--get-url', '$remote', '--exit-code'],
77+
runInShell: any(named: 'runInShell'),
78+
workingDirectory: any(named: 'workingDirectory'),
79+
),
80+
).called(1);
81+
});
82+
6783
test(
6884
'throws UnreachableGitDependency for an unreachable remote',
6985
() async {

0 commit comments

Comments
 (0)