checkout: Only run 'git clean' when not using repo
'git clean' at the top level doesn't make sense in repo checkouts.
Change-Id: I2ce61c541bb98da7df6a288921adac7d6fc89ee7
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/216356
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index 444af57..f7507c8 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -1564,12 +1564,13 @@
self._workspace(ctx)
- with self.m.context(cwd=ctx.root):
- self.m.git.clean(force=2, recursive=True)
- try:
- self.m.git.status()
- except self.m.step.StepFailure: # pragma: no cover
- pass
+ if not options.use_repo:
+ with self.m.context(cwd=ctx.root):
+ self.m.git.clean(force=2, recursive=True)
+ try:
+ self.m.git.status()
+ except self.m.step.StepFailure: # pragma: no cover
+ pass
ctx.status = self._check_unapplied_changes(ctx.changes)
diff --git a/recipe_modules/checkout/tests/repo.expected/ci.json b/recipe_modules/checkout/tests/repo.expected/ci.json
index a991c75..f36cf80 100644
--- a/recipe_modules/checkout/tests/repo.expected/ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/ci.json
@@ -731,33 +731,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
index 5785a0d..22983f5 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
@@ -1043,57 +1043,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:ci"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:ci"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
index 4470318..bfbb400 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
@@ -1206,57 +1206,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
index 28926ca..4723f98 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
@@ -1656,57 +1656,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
index e709bf7..67cd52c 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
@@ -1565,57 +1565,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/no_trigger.json b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
index cdf3d90..6703e52 100644
--- a/recipe_modules/checkout/tests/repo.expected/no_trigger.json
+++ b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
@@ -728,33 +728,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/prefix.json b/recipe_modules/checkout/tests/repo.expected/prefix.json
index b4fb109..e4c5a8e 100644
--- a/recipe_modules/checkout/tests/repo.expected/prefix.json
+++ b/recipe_modules/checkout/tests/repo.expected/prefix.json
@@ -1153,57 +1153,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
index ad190fb..2b3a0f1 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
@@ -1796,57 +1796,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
index 9bba215..292e2fd 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
@@ -1642,57 +1642,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.some changes were not applied",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple.json b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
index adfbe83..9e6d87c 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
@@ -1567,57 +1567,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try.json b/recipe_modules/checkout/tests/repo.expected/try.json
index a00cf20..709fcb5 100644
--- a/recipe_modules/checkout/tests/repo.expected/try.json
+++ b/recipe_modules/checkout/tests/repo.expected/try.json
@@ -1157,57 +1157,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
index 9b6d592..57044f4 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
@@ -1225,57 +1225,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co/foo",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [
diff --git a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
index 0d9e188..1ab20ca 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
@@ -815,57 +815,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.no changes were applied",
"~followup_annotations": [
diff --git a/recipes/target_to_cipd.expected/success.json b/recipes/target_to_cipd.expected/success.json
index 80247cd..5b461fd 100644
--- a/recipes/target_to_cipd.expected/success.json
+++ b/recipes/target_to_cipd.expected/success.json
@@ -1007,57 +1007,6 @@
]
},
{
- "cmd": [
- "git",
- "clean",
- "-f",
- "-f",
- "-d"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:ci"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git clean",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "status"
- ],
- "cwd": "[START_DIR]/co",
- "luci_context": {
- "realm": {
- "name": "project:ci"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checkout pigweed.git status",
- "timeout": 600.0,
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
"cmd": [],
"name": "checkout pigweed.status",
"~followup_annotations": [