Skip to content

Commit

Permalink
Merge pull request #7 from coherent-oss/tag-command
Browse files Browse the repository at this point in the history
Implement `coh tag` command
  • Loading branch information
jaraco authored Aug 30, 2024
2 parents a266b5d + 53f5cc9 commit 101d534
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
__requires__ = [
'coherent.build',
'coherent.test',
'jaraco.vcs',
'jaraco.versioning',
'typer',
'typing-extensions',
]
25 changes: 25 additions & 0 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
import runpy
import subprocess
import sys
from typing_extensions import Annotated

import typer
from coherent.build import bootstrap
from jaraco.vcs import Repo
from jaraco.versioning import Versioned, semver


app = typer.Typer()
Expand Down Expand Up @@ -35,5 +38,27 @@ def build() -> None:
runpy.run_module('coherent.build', run_name='__main__')


@app.command(context_settings=dict(allow_extra_args=True))
def tag(
kind_or_name: str,
context: typer.Context,
repository: Annotated[
Repo,
typer.Option(
'-R', '--repository',
help='Path to repository.',
parser=Repo.detect,
),
] = '.',
) -> None:
if kind_or_name in Versioned.semantic_increment:
name = repository.get_next_version(kind_or_name)
else:
name = kind_or_name
args = ['-a', semver(name), '-m', '', *context.args]
subprocess.run(['git', '-C', repository.location, 'tag', *args], check=True)
print(f"Created tag {name}")


if __name__ == '__main__':
app()

0 comments on commit 101d534

Please sign in to comment.