Repository navigation
Expand file tree
/
Copy pathosc-get-pr-status
More file actions
executable file
·53 lines (40 loc) · 1.77 KB
/
Copy pathosc-get-pr-status
File metadata and controls
executable file
·53 lines (40 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""Report unresolvable build dependencies of an OBS project from osc results."""
import subprocess
import typer
app = typer.Typer(help="Extract CI/Build results and unresolvable reasons from OBS.")
def get_detailed_results(project: str, package: str) -> str:
"""Fetch detailed build results using 'osc results -v'."""
try:
result = subprocess.run(["osc", "results", "-v", project, package], capture_output=True, text=True, check=True)
except subprocess.CalledProcessError as e:
typer.echo(f"Error running osc: {e.stderr}", err=True)
return ""
return result.stdout
def parse_unresolvables(output: str) -> list[str]:
"""Parse the output of 'osc results -v' to extract the 'nothing provides' lines."""
lines = output.splitlines()
unresolvables = [line.strip() for line in lines if "nothing provides" in line]
return sorted(set(unresolvables))
@app.command()
def extract(
project: str = typer.Argument(..., help="The OBS project name (e.g. home:user:matrix)"),
package: str = typer.Argument("matrix-synapse", help="The OBS package name"),
verbose: bool = typer.Option(False, "--verbose", "-v", help="Print full output instead of just unresolvables"),
) -> None:
"""Extract unresolvable dependencies from OBS build results."""
output = get_detailed_results(project, package)
if not output:
raise typer.Exit(code=1)
if verbose:
typer.echo(output)
return
unresolvables = parse_unresolvables(output)
if not unresolvables:
typer.echo("No unresolvable issues found or build is still pending.")
else:
typer.echo("\n--- Unresolvable Dependencies ---")
for item in unresolvables:
typer.echo(item)
if __name__ == "__main__":
app()