This commit is contained in:
parent
3b5981d9cd
commit
d830965d7a
1 changed files with 13 additions and 2 deletions
15
verify.py
15
verify.py
|
@ -28,7 +28,7 @@ def collect_user_dirs():
|
||||||
|
|
||||||
def last_commit_for(dir: Path, ref: git.Reference):
|
def last_commit_for(dir: Path, ref: git.Reference):
|
||||||
"""Returns the Git commit signature for the last commit on this path."""
|
"""Returns the Git commit signature for the last commit on this path."""
|
||||||
last_commit_hash = str(ref.repo.git.rev_list("--max-count=1", action_ref, dir))
|
last_commit_hash = str(ref.repo.git.rev_list("--max-count=1", ref, dir))
|
||||||
return ref.repo.commit(last_commit_hash)
|
return ref.repo.commit(last_commit_hash)
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,18 @@ def verify_dir(dir: Path, ref: git.Reference):
|
||||||
|
|
||||||
|
|
||||||
def current_ref(repo: git.Repo) -> git.Reference:
|
def current_ref(repo: git.Repo) -> git.Reference:
|
||||||
for ref in repo.references:
|
log.debug(f"{repo.references}")
|
||||||
|
# some of this logic stolen from https://code.forgejo.org/actions/checkout/src/branch/main/src/ref-helper.ts - the ref names github provides are beyond fucked
|
||||||
|
global action_ref
|
||||||
|
if (action_ref.startswith('refs/heads/')):
|
||||||
|
branch = action_ref.removeprefix('refs/heads/')
|
||||||
|
action_ref = branch
|
||||||
|
# refs/pull/
|
||||||
|
elif (action_ref.startswith('refs/pull/')):
|
||||||
|
branch = action_ref.removeprefix('refs/pull/')
|
||||||
|
action_ref = f'refs/remotes/pull/{branch}'
|
||||||
|
|
||||||
|
for ref in repo.refs:
|
||||||
if ref.name == action_ref or ref.path == action_ref:
|
if ref.name == action_ref or ref.path == action_ref:
|
||||||
return ref
|
return ref
|
||||||
raise Exception(f"No ref named {action_ref} found")
|
raise Exception(f"No ref named {action_ref} found")
|
||||||
|
|
Loading…
Add table
Reference in a new issue