Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion github_scripts/get_git_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

logger = logging.getLogger(__name__)

# Match hex commit IDs for both SHA-1 and SHA-256 repositories.
_hash_pattern = re.compile(r"^\s*([0-9a-f]{40}(?:[0-9a-f]{24})?)\s*")


class SubprocessRunError(Exception):
def __init__(self, command, returncode, stdout, stderr):
Expand Down Expand Up @@ -351,7 +354,7 @@ def determine_mirror_fetch(repo_source: str, repo_ref: str) -> str:

# If the ref is a hash then we don't need the fork user as part of the fetch.
# Equally, if the user is the Upstream User, it's not needed
if not user or re.match(r"^\s*([0-9a-f]{40})\s*$", repo_ref):
if not user or re.match(_hash_pattern, repo_ref):
fetch = repo_ref
else:
fetch = f"{user}/{repo_ref}"
Expand Down
4 changes: 2 additions & 2 deletions github_scripts/git_bdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class GitBDiff(GitBase):
# Name of primary branch - default is main
primary_branch = "main"

# Match hex commit IDs
_hash_pattern = re.compile(r"^\s*([0-9a-f]{40})\s*$")
# Match hex commit IDs for both SHA-1 and SHA-256 repositories.
_hash_pattern = re.compile(r"^\s*([0-9a-f]{40}(?:[0-9a-f]{24})?)\s*")

def __init__(self, parent=None, repo=None):
self.parent = parent or self.primary_branch
Expand Down
5 changes: 4 additions & 1 deletion github_scripts/suite_report_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

from suite_data import SuiteData

# Match hex commit IDs for both SHA-1 and SHA-256 repositories.
_hash_pattern = re.compile(r"^\s*([0-9a-f]{40}(?:[0-9a-f]{24})?)\s*")


def create_markdown_row(*columns: str, header=False) -> List[str]:
"""
Expand Down Expand Up @@ -151,7 +154,7 @@ def create_dependency_table(self) -> None:
org_repo = extract_org_repo(reference)

# Check if the ref is a hash and use short form if so
if re.match(r"^\s*([0-9a-f]{40})\s*$", ref):
if re.match(_hash_pattern, ref):
ref = ref[:7]
url = f"https://github.com/{org_repo}/tree/{ref}"
reference = f"[{org_repo}@{ref}]({url})"
Expand Down