Skip to content

Commit a756dcb

Browse files
author
aelhounsri
committed
Fixed the issue with somef config resetting at every command, preparing for 0.2.1 release
1 parent 7a3314c commit a756dcb

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "metacheck"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "Detect metadata pitfalls in software repositories"
55
authors = ["Anas El Hounsri"]
66
readme = "README.md"

src/metacheck/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import os
33
from pathlib import Path
4-
from metacheck.run_somef import run_somef_batch, run_somef_single, configure_somef
4+
from metacheck.run_somef import run_somef_batch, run_somef_single, ensure_somef_configured
55
from metacheck.run_analyzer import run_analysis
66

77

@@ -66,8 +66,7 @@ def cli():
6666
run_analysis(somef_json_paths, args.pitfalls_output, args.analysis_output, verbose=args.verbose)
6767

6868
else:
69-
# Before taking any SoMEF actions, configure it
70-
configure_somef()
69+
ensure_somef_configured()
7170

7271
threshold = args.threshold
7372
somef_output_dir = args.somef_output

src/metacheck/run_somef.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
import json
33
import subprocess
44

5-
def configure_somef():
6-
"""Automatically run 'somef configure -a' if not already configured."""
7-
print("Configuring SoMEF...")
8-
try:
9-
subprocess.run(["somef", "configure", "-a"], check=True)
10-
print("SoMEF configured successfully.")
11-
return True
12-
except subprocess.CalledProcessError as e:
13-
print(f"Error configuring SoMEF: {e}")
14-
return False
5+
from pathlib import Path
6+
7+
def ensure_somef_configured():
8+
"""Run 'somef configure -a' only if it hasn't been configured yet."""
9+
config_file = Path.home() / ".somef" / "config.json"
10+
if not config_file.exists():
11+
print("SoMEF configuration not found. Running initial setup...")
12+
try:
13+
subprocess.run(["somef", "configure", "-a"], check=True)
14+
print("SoMEF configured successfully.")
15+
return True
16+
except subprocess.CalledProcessError as e:
17+
print(f"Error configuring SoMEF: {e}")
18+
return False
19+
return True
1520

1621
def run_somef(repo_url, output_file, threshold):
1722
"""Run SoMEF on a given repository and save results."""

0 commit comments

Comments
 (0)