Skip to content

Commit

Permalink
simplify some of this code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwlchan committed May 15, 2023
1 parent a0a1da4 commit a60d180
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions scripts/generate_miro_image_suppressions_table.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/usr/bin/env python3

import contextlib
import os
import shutil
import subprocess
import sys
import tempfile


def git(*args):
"""Run a Git command and return its output."""
subprocess.check_call(["git"] + list(args))


@contextlib.contextmanager
def working_directory(path):
"""
Expand All @@ -33,15 +24,11 @@ def cloned_repo(git_url):
Clones the repository and changes the working directory to the cloned
repo. Cleans up the clone when it's done.
"""
repo_dir = tempfile.mkdtemp()
with tempfile.TemporaryDirectory() as repo_dir:
subprocess.check_call(["git", "clone", git_url, repo_dir])

git("clone", git_url, repo_dir)

try:
with working_directory(repo_dir):
yield
finally:
shutil.rmtree(repo_dir)


def get_github_api_key(sess):
Expand Down

0 comments on commit a60d180

Please sign in to comment.