From a69b765a6ad6592358cbf42a2a68da5b1815ca90 Mon Sep 17 00:00:00 2001 From: "unicoderbot[bot]" <269805761+unicoderbot[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 15:39:33 +0000 Subject: [PATCH 1/2] feat: add --get-url flag to git ls-remote for URL config overrides Closes #1097 Co-authored-by: marcossevilla --- lib/src/cli/git_cli.dart | 5 +++++ test/src/cli/git_cli_test.dart | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/src/cli/git_cli.dart b/lib/src/cli/git_cli.dart index 7f96c19b3..871baf47e 100644 --- a/lib/src/cli/git_cli.dart +++ b/lib/src/cli/git_cli.dart @@ -21,10 +21,15 @@ Make sure the remote exists and you have the correct access rights.'''; /// Git CLI class Git { /// Determine whether the [remote] is reachable. + /// + /// The check honors `url..insteadOf` git config overrides by passing + /// `--get-url` to `git ls-remote`, mirroring how the actual pull would + /// resolve the remote. static Future reachable(Uri remote, {required Logger logger}) async { try { await _Cmd.run('git', [ 'ls-remote', + '--get-url', '$remote', '--exit-code', ], logger: logger); diff --git a/test/src/cli/git_cli_test.dart b/test/src/cli/git_cli_test.dart index be911ff36..222a16b7a 100644 --- a/test/src/cli/git_cli_test.dart +++ b/test/src/cli/git_cli_test.dart @@ -64,6 +64,22 @@ void main() { }, runProcess: process.run); }); + test('passes --get-url to respect insteadOf overrides', () async { + final remote = Uri.parse('https://github.com/org/repo'); + await ProcessOverrides.runZoned(() async { + await Git.reachable(remote, logger: logger); + }, runProcess: process.run); + + verify( + () => process.run( + 'git', + ['ls-remote', '--get-url', '$remote', '--exit-code'], + runInShell: any(named: 'runInShell'), + workingDirectory: any(named: 'workingDirectory'), + ), + ).called(1); + }); + test( 'throws UnreachableGitDependency for an unreachable remote', () async { From 4142b8f6b6302dd4326044f0cefcc915baa5013b Mon Sep 17 00:00:00 2001 From: Marcos Sevilla <31174242+marcossevilla@users.noreply.github.com> Date: Tue, 7 Jul 2026 17:45:23 +0200 Subject: [PATCH 2/2] Apply suggestion from @marcossevilla --- lib/src/cli/git_cli.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/src/cli/git_cli.dart b/lib/src/cli/git_cli.dart index 871baf47e..21f4d80cd 100644 --- a/lib/src/cli/git_cli.dart +++ b/lib/src/cli/git_cli.dart @@ -21,10 +21,6 @@ Make sure the remote exists and you have the correct access rights.'''; /// Git CLI class Git { /// Determine whether the [remote] is reachable. - /// - /// The check honors `url..insteadOf` git config overrides by passing - /// `--get-url` to `git ls-remote`, mirroring how the actual pull would - /// resolve the remote. static Future reachable(Uri remote, {required Logger logger}) async { try { await _Cmd.run('git', [