Skip to content

Commit 69c18fb

Browse files
Added branch repo targeting, improved evidence report and started addresssing dynamic suggestions #65
2 parents abe2fc0 + 77a7fc4 commit 69c18fb

5 files changed

Lines changed: 194 additions & 37 deletions

File tree

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,12 @@ coverage/
129129

130130
# Data files (adjust depending on project)
131131
data/
132-
datasets/
132+
datasets/
133+
134+
# uv
135+
uv.lock
136+
.python-version
137+
138+
# Testing directory
139+
140+
results/

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18956787.svg)](https://doi.org/10.5281/zenodo.18956787)
22
![PyPI - Version](https://img.shields.io/pypi/v/rsmetacheck)
33

4-
54
# Research Software MetaCheck (a Pitfall/Warning Detection Tool)
65

76
This project provides an automated tool for detecting common metadata quality issues (pitfalls & Warnings)
@@ -28,7 +27,7 @@ The tool detects the following categories of issues:
2827

2928
## Requirements
3029

31-
- **Python 3.10**
30+
- **Python 3.11**
3231
- Required Python packages:
3332
- `requests` (for URL validation)
3433
- `pathlib` (built-in)
@@ -78,6 +77,14 @@ pip install git+https://github.com/SoftwareUnderstanding/RsMetaCheck.git
7877
poetry run rsmetacheck --input https://github.com/tidyverse/tidyverse
7978
```
8079

80+
#### Analyze a Specific Branch
81+
82+
You can analyze a specific branch of a repository by using the `--branch` or `-b` flag:
83+
84+
```bash
85+
poetry run rsmetacheck --input https://github.com/tidyverse/tidyverse --branch develop
86+
```
87+
8188
#### Analyze Multiple Repositories from a JSON File
8289

8390
```bash

src/rsmetacheck/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def cli():
3939
default=0.8,
4040
help="SoMEF confidence threshold (default: 0.8). Only used when running SoMEF."
4141
)
42+
parser.add_argument(
43+
"-b", "--branch",
44+
help="Branch of the repository to analyze. Overrides the default branch. Only used when running SoMEF."
45+
)
4246

4347
parser.add_argument(
4448
"--verbose",
@@ -76,10 +80,10 @@ def cli():
7680
for input_item in args.input:
7781
if input_item.startswith("http://") or input_item.startswith("https://"):
7882
print(f"Processing repository URL: {input_item}")
79-
run_somef_single(input_item, somef_output_dir, threshold)
83+
run_somef_single(input_item, somef_output_dir, threshold, branch=args.branch)
8084
elif os.path.exists(input_item):
8185
print(f"Processing repositories from file: {input_item}")
82-
run_somef_batch(input_item, somef_output_dir, threshold)
86+
run_somef_batch(input_item, somef_output_dir, threshold, branch=args.branch)
8387
else:
8488
print(f"Warning: Skipping invalid input (not a URL or existing file): {input_item}")
8589

src/rsmetacheck/run_somef.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ def ensure_somef_configured():
1818
return False
1919
return True
2020

21-
def run_somef(repo_url, output_file, threshold):
21+
def run_somef(repo_url, output_file, threshold, branch=None):
2222
"""Run SoMEF on a given repository and save results."""
23+
cmd = ["somef", "describe", "-r", repo_url, "-o", output_file, "-t", str(threshold)]
24+
if branch:
25+
cmd.extend(["-b", branch])
2326
try:
24-
subprocess.run(
25-
["somef", "describe", "-r", repo_url, "-o", output_file, "-t", str(threshold)],
26-
check=True
27-
)
27+
subprocess.run(cmd, check=True)
2828
print(f"SoMEF finished for: {repo_url}")
2929
return True
3030
except subprocess.CalledProcessError as e:
3131
print(f"Error running SoMEF for {repo_url}: {e}")
3232
return False
3333

34-
def run_somef_single(repo_url, output_dir="somef_outputs", threshold=0.8):
34+
def run_somef_single(repo_url, output_dir="somef_outputs", threshold=0.8, branch=None):
3535
"""Run SoMEF for a single repository."""
3636
os.makedirs(output_dir, exist_ok=True)
3737
output_file = os.path.join(output_dir, "output_1.json")
3838

3939
print(f"Running SoMEF for {repo_url}...")
40-
success = run_somef(repo_url, output_file, threshold)
40+
success = run_somef(repo_url, output_file, threshold, branch)
4141
return output_dir if success else None
4242

43-
def run_somef_batch(json_file, output_dir="somef_outputs", threshold=0.8):
43+
def run_somef_batch(json_file, output_dir="somef_outputs", threshold=0.8, branch=None):
4444
"""Run SoMEF for all repositories listed in a JSON file."""
4545
os.makedirs(output_dir, exist_ok=True)
4646

@@ -58,7 +58,7 @@ def run_somef_batch(json_file, output_dir="somef_outputs", threshold=0.8):
5858
for idx, repo_url in enumerate(repos, start=1):
5959
output_file = os.path.join(output_dir, f"{base_name}_output_{idx}.json")
6060
print(f"[{idx}/{len(repos)}] {repo_url}")
61-
run_somef(repo_url, output_file, threshold)
61+
run_somef(repo_url, output_file, threshold, branch)
6262

6363
print(f"Completed SoMEF for {base_name}. Results in {output_dir}")
6464
return True

0 commit comments

Comments
 (0)