Add since command
All checks were successful
test / test (push) Successful in 1m7s
build / build (push) Successful in 2m21s
test / test (pull_request) Successful in 47s
build / build (pull_request) Successful in 2m21s

This commit is contained in:
Torjus Håkestad 2024-10-06 19:39:42 +02:00
parent 670c6c738e
commit de64f73c46

View File

@ -1,7 +1,9 @@
import typer
import json
from typing import Annotated
from rich.console import Console
from nixprstatus.pr import pr_merge_status
from nixprstatus.pr import commits_since
app = typer.Typer()
@ -38,6 +40,26 @@ def pr(
console.print(output, highlight=False)
@app.command()
def since(
commit_sha: str,
target: str = "nixos-unstable",
waybar_format: Annotated[
bool, typer.Option(help="Output in format expected by waybar")
] = False,
):
"""
Return the count of commits that has happened between the two refs.
"""
count = commits_since(target, commit_sha)
if waybar_format:
output = {"text": str(count), "tooltip": f"{target}: {count}"}
typer.echo(json.dumps(output))
return
typer.echo(count)
def main():
app()