Skip to content

Commit

Permalink
Add commit tag context extension
Browse files Browse the repository at this point in the history
  • Loading branch information
neoxelox committed Jul 16, 2022
1 parent 032dde6 commit 198c9db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions superinvoke/extensions/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def branch(context: Context) -> str:
return context.attempt("git rev-parse --abbrev-ref HEAD")


# Gets the current commit tag if any.
def tag(context: Context) -> Optional[str]:
result = context.attempt("git name-rev --name-only --tags HEAD")
return result if result != "undefined" else None


# Gets the N last changes.
def changes(context: Context, scope: int = 1) -> List[str]:
return context.attempt(f"git diff --name-only HEAD HEAD~{scope}").split("\n")
Expand Down Expand Up @@ -197,6 +203,7 @@ def init() -> None:
Context.repository = repository
Context.commit = commit
Context.branch = branch
Context.tag = tag
Context.changes = changes
Context.create = create
Context.read = read
Expand Down

0 comments on commit 198c9db

Please sign in to comment.