Don't pass an empty refspec to git fetch in gn trybuilds gn trybots are currently failing during "git.fetch" with HTTP 400 errors, eg: https://ci.chromium.org/b/8664323423796267793/infra In protobuf, build_input.gitiles_commit is always truthy even when unset. So on trybuilds, ref evaluates to "", meaning the recipe has been running `git fetch --tags https://gn.googlesource.com/gn ""`. That used to work fine. According to jetski, git expands "" under protocol v2 into a "ref-prefix refs/remotes//HEAD" ls-refs arg. But git-on-borg recently started rejecting that as an invalid ref name due to the double slash. So this checks build_input.gitiles_commit.id instead, and falls back to "refs/heads/main" (instead of the old "refs/heads/master"). No-try: true Bug: None Change-Id: I6ceb36c8f4e73b479289f08bbf637ef045be700a Reviewed-on: https://gn-review.googlesource.com/c/gn/+/29420 Reviewed-by: Andrew Grieve <agrieve@google.com> Commit-Queue: Ben Pastene <bpastene@chromium.org>
diff --git a/infra/recipes/gn.expected/cq_linux.json b/infra/recipes/gn.expected/cq_linux.json index 3942c4d..5708863 100644 --- a/infra/recipes/gn.expected/cq_linux.json +++ b/infra/recipes/gn.expected/cq_linux.json
@@ -33,7 +33,7 @@ "fetch", "--tags", "https://gn.googlesource.com/gn", - "" + "refs/heads/main" ], "cwd": "[START_DIR]/gn", "infra_step": true,
diff --git a/infra/recipes/gn.expected/cq_mac.json b/infra/recipes/gn.expected/cq_mac.json index 402ce4f..48d5f72 100644 --- a/infra/recipes/gn.expected/cq_mac.json +++ b/infra/recipes/gn.expected/cq_mac.json
@@ -33,7 +33,7 @@ "fetch", "--tags", "https://gn.googlesource.com/gn", - "" + "refs/heads/main" ], "cwd": "[START_DIR]/gn", "infra_step": true,
diff --git a/infra/recipes/gn.expected/cq_win.json b/infra/recipes/gn.expected/cq_win.json index 474d598..a620ac5 100644 --- a/infra/recipes/gn.expected/cq_win.json +++ b/infra/recipes/gn.expected/cq_win.json
@@ -33,7 +33,7 @@ "fetch", "--tags", "https://gn.googlesource.com/gn", - "" + "refs/heads/main" ], "cwd": "[START_DIR]\\gn", "infra_step": true,
diff --git a/infra/recipes/gn.py b/infra/recipes/gn.py index e404ddb..5cd3f37 100644 --- a/infra/recipes/gn.py +++ b/infra/recipes/gn.py
@@ -96,9 +96,7 @@ with api.context(cwd=src_dir): build_input = api.buildbucket.build_input - ref = ( - build_input.gitiles_commit.id - if build_input.gitiles_commit else 'refs/heads/master') + ref = build_input.gitiles_commit.id or 'refs/heads/main' # Fetch tags so `git describe` works. api.step('fetch', ['git', 'fetch', '--tags', repository, ref]) api.step('checkout', ['git', 'checkout', 'FETCH_HEAD'])