summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDylan Baker <dylan.c.baker@intel.com>2022-03-17 10:30:57 -0700
committerDylan Baker <dylan.c.baker@intel.com>2022-03-23 09:10:04 -0700
commit3348844bc45b4204619f77949d09a4ecebc402f3 (patch)
tree9d9eebbbda3784d922963b30f3cdf15d76f78314 /bin
parent29960e0b4ad5ca399356472aea936b98b397ac2a (diff)
pick/core: Add a method for updating commits
This is almost the same as the one in the ui, but without the UI elements. It would be nice to share code between them, but I'm not sure how to do that yet.
Diffstat (limited to 'bin')
-rw-r--r--bin/pick/core.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/pick/core.py b/bin/pick/core.py
index e10f7416580..fe5af9d8db2 100644
--- a/bin/pick/core.py
+++ b/bin/pick/core.py
@@ -22,6 +22,7 @@
import asyncio
import enum
+import itertools
import json
import pathlib
import re
@@ -372,6 +373,25 @@ async def gather_commits(version: str, previous: typing.List['Commit'],
return commits
+async def update_commits() -> None:
+ """Gather all new commits and update the on-disk cache.
+ """
+ commits = load()
+ with open('VERSION', 'r') as f:
+ version = '.'.join(f.read().split('.')[:2])
+ if commits:
+ sha = commits[0].sha
+ else:
+ sha = f'{version}-branchpoint'
+
+ if new := await get_new_commits(sha):
+ collected_commits = await gather_commits(version, commits, new)
+ else:
+ collected_commits = []
+
+ save(itertools.chain(collected_commits, commits))
+
+
def load() -> typing.List['Commit']:
if not pick_status_json.exists():
return []