Skip to content

Commit 2ddb1df

Browse files
authored
Merge pull request #17 from PepperDash/update-script
ci: copilot suggestions and count field change
2 parents 4b88d76 + fe3c3a5 commit 2ddb1df

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

.github/scripts/gather_repo_urls.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,30 @@ def extract_pepperdash_essentials_package_version(repo):
4242
if file_content.type == "dir":
4343
contents.extend(repo.get_contents(file_content.path))
4444
elif file_content.type == "file":
45+
# Fetch file content only once per file
46+
file_data = None
47+
4548
# Check packages.config files
4649
if file_content.name == "packages.config":
4750
logging.debug(f"Found packages.config file: {file_content.path}")
4851
file_data = repo.get_contents(file_content.path).decoded_content.decode("utf-8")
49-
# Look for PepperDashEssentials package in packages.config
50-
match = re.search(r'<package\s+id="PepperDashEssentials"\s+version="([^"]+)"', file_data)
51-
if match:
52-
version = match.group(1).strip()
53-
logging.debug(f"Found PepperDashEssentials version in packages.config: {version}")
54-
return version
52+
# Look for PepperDashEssentials package in packages.config (attribute order agnostic)
53+
for pkg_match in re.finditer(r'<package\b[^>]*>', file_data):
54+
pkg_tag = pkg_match.group(0)
55+
id_match = re.search(r'id="([^"]+)"', pkg_tag)
56+
version_match = re.search(r'version="([^"]+)"', pkg_tag)
57+
if id_match and id_match.group(1) == "PepperDashEssentials" and version_match:
58+
version = version_match.group(1).strip()
59+
logging.debug(f"Found PepperDashEssentials version in packages.config: {version}")
60+
return version
5561

5662
# Check .csproj files for PackageReference
5763
elif file_content.name.endswith(".csproj"):
5864
logging.debug(f"Found csproj file: {file_content.path}")
59-
file_data = repo.get_contents(file_content.path).decoded_content.decode("utf-8")
60-
# Look for PackageReference to PepperDashEssentials
61-
match = re.search(r'<PackageReference\s+Include="PepperDashEssentials"\s+Version="([^"]+)"', file_data)
65+
if file_data is None:
66+
file_data = repo.get_contents(file_content.path).decoded_content.decode("utf-8")
67+
# Look for PackageReference to PepperDashEssentials (attribute order agnostic)
68+
match = re.search(r'<PackageReference\b[^>]*\bInclude="PepperDashEssentials"[^>]*\bVersion="([^"]+)"', file_data)
6269
if match:
6370
version = match.group(1).strip()
6471
logging.debug(f"Found PepperDashEssentials version in csproj: {version}")
@@ -154,7 +161,7 @@ def process_repositories(repo_list):
154161
if result:
155162
results.append(result)
156163
total_epi_repos += 1
157-
norm = normalize_release_tag(result["min_essentials"], result["repo_name"])
164+
norm = normalize_release_tag(result["package_version"], result["repo_name"])
158165
if norm == "1":
159166
total_release_1_x += 1
160167
elif norm == "2":

0 commit comments

Comments
 (0)