Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6484430

Browse files
authored
Limit scope of --no-branch option in typeshed script (#20880)
Followup to #20873. Limit the `--no-branch` option to just the `git checkout` command. This fixes a small issue where `typeshed_patches` isn't defined with `--no-branch` selected. It's used later in the script as well.
1 parent c2bda2b commit 6484430

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

misc/sync-typeshed.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,20 @@ def main() -> None:
153153
raise ValueError("GITHUB_TOKEN environment variable must be set")
154154

155155
with tempfile.TemporaryDirectory() as tmpdir:
156-
if not args.no_branch:
157-
# Stash patches before checking out a new branch
158-
typeshed_patches = os.path.join("misc", "typeshed_patches")
159-
tmp_patches = os.path.join(tmpdir, "typeshed_patches")
160-
shutil.copytree(typeshed_patches, tmp_patches)
156+
# Stash patches before checking out a new branch
157+
typeshed_patches = os.path.join("misc", "typeshed_patches")
158+
tmp_patches = os.path.join(tmpdir, "typeshed_patches")
159+
shutil.copytree(typeshed_patches, tmp_patches)
161160

162-
branch_name = "mypybot/sync-typeshed"
161+
branch_name = "mypybot/sync-typeshed"
162+
if not args.no_branch:
163163
subprocess.run(["git", "checkout", "-B", branch_name, "origin/master"], check=True)
164164

165-
# Copy the stashed patches back
166-
shutil.rmtree(typeshed_patches, ignore_errors=True)
167-
shutil.copytree(tmp_patches, typeshed_patches)
168-
if (
169-
subprocess.run(["git", "diff", "--quiet", "--exit-code"], check=False).returncode
170-
!= 0
171-
):
172-
subprocess.run(["git", "commit", "-am", "Update typeshed patches"], check=True)
165+
# Copy the stashed patches back
166+
shutil.rmtree(typeshed_patches, ignore_errors=True)
167+
shutil.copytree(tmp_patches, typeshed_patches)
168+
if subprocess.run(["git", "diff", "--quiet", "--exit-code"], check=False).returncode != 0:
169+
subprocess.run(["git", "commit", "-am", "Update typeshed patches"], check=True)
173170

174171
if not args.typeshed_dir:
175172
tmp_typeshed = os.path.join(tmpdir, "typeshed")

0 commit comments

Comments
 (0)