aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/llvm_project.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_tools/llvm_project.py')
-rw-r--r--llvm_tools/llvm_project.py81
1 files changed, 46 insertions, 35 deletions
diff --git a/llvm_tools/llvm_project.py b/llvm_tools/llvm_project.py
index 3dba9ffe..85b4a0c2 100644
--- a/llvm_tools/llvm_project.py
+++ b/llvm_tools/llvm_project.py
@@ -17,48 +17,59 @@ import git_llvm_rev
def get_location() -> str:
- """Gets the absolute path for llvm-project-copy."""
- my_dir = os.path.dirname(os.path.abspath(__file__))
- return os.path.join(my_dir, 'llvm-project-copy')
+ """Gets the absolute path for llvm-project-copy."""
+ my_dir = os.path.dirname(os.path.abspath(__file__))
+ return os.path.join(my_dir, "llvm-project-copy")
def ensure_up_to_date():
- """Ensures that llvm-project-copy is checked out and semi-up-to-date."""
+ """Ensures that llvm-project-copy is checked out and semi-up-to-date."""
- checkout = get_location()
- if not os.path.isdir(checkout):
- print('No llvm-project exists locally; syncing it. This takes a while.',
- file=sys.stderr)
- actual_checkout = get_llvm_hash.GetAndUpdateLLVMProjectInLLVMTools()
- assert checkout == actual_checkout, '%s != %s' % (actual_checkout,
- checkout)
+ checkout = get_location()
+ if not os.path.isdir(checkout):
+ print(
+ "No llvm-project exists locally; syncing it. This takes a while.",
+ file=sys.stderr,
+ )
+ actual_checkout = get_llvm_hash.GetAndUpdateLLVMProjectInLLVMTools()
+ assert checkout == actual_checkout, "%s != %s" % (
+ actual_checkout,
+ checkout,
+ )
- commit_timestamp = subprocess.check_output(
- [
- 'git', 'log', '-n1', '--format=%ct',
- 'origin/' + git_llvm_rev.MAIN_BRANCH
- ],
- cwd=checkout,
- encoding='utf-8',
- )
+ commit_timestamp = subprocess.check_output(
+ [
+ "git",
+ "log",
+ "-n1",
+ "--format=%ct",
+ "origin/" + git_llvm_rev.MAIN_BRANCH,
+ ],
+ cwd=checkout,
+ encoding="utf-8",
+ )
- commit_time = datetime.datetime.fromtimestamp(int(commit_timestamp.strip()))
- now = datetime.datetime.now()
+ commit_time = datetime.datetime.fromtimestamp(int(commit_timestamp.strip()))
+ now = datetime.datetime.now()
- time_since_last_commit = now - commit_time
+ time_since_last_commit = now - commit_time
- # Arbitrary, but if it's been more than 2d since we've seen a commit, it's
- # probably best to bring us up-to-date.
- if time_since_last_commit <= datetime.timedelta(days=2):
- return
+ # Arbitrary, but if it's been more than 2d since we've seen a commit, it's
+ # probably best to bring us up-to-date.
+ if time_since_last_commit <= datetime.timedelta(days=2):
+ return
- print('%d days have elapsed since the last commit to %s; auto-syncing' %
- (time_since_last_commit.days, checkout),
- file=sys.stderr)
+ print(
+ "%d days have elapsed since the last commit to %s; auto-syncing"
+ % (time_since_last_commit.days, checkout),
+ file=sys.stderr,
+ )
- result = subprocess.run(['git', 'fetch', 'origin'],
- check=False,
- cwd=checkout)
- if result.returncode:
- print('Sync failed somehow; hoping that things are fresh enough, then...',
- file=sys.stderr)
+ result = subprocess.run(
+ ["git", "fetch", "origin"], check=False, cwd=checkout
+ )
+ if result.returncode:
+ print(
+ "Sync failed somehow; hoping that things are fresh enough, then...",
+ file=sys.stderr,
+ )