Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ All of them are **optional**.

- **abbrev** (Int): Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <n> digits, or as many digits as needed to form a unique object name. An <n> of 0 will suppress long format, only showing the closest tag.
- **all** (Boolean): Instead of using only the annotated tags, use any ref found in refs/ namespace. This option enables matching any known branch, remote-tracking branch, or lightweight tag.
- **always** (Boolean): Show uniquely abbreviated commit object as fallback. Useful to avoid the "No names found, cannot describe anything." error in case no git tag exists.
- **broken** (String): Describe the state of the working tree. If a repository is corrupt and Git cannot determine if there is local modification, Git will error out, unless ‘--broken’ is given, which appends the suffix provided by this option instead.
- **commit-ish** (String): Commit-ish object names to describe. Defaults to HEAD if omitted.
- **dirty** (String): Describe the state of the working tree[<sup>[1]</sup>](#dirty-parsing). If the working tree has local modifications the suffix provided by this option is appended to it.
Expand Down
3 changes: 3 additions & 0 deletions components/git_ref/text_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
cv.Optional("all", default=False): cv.boolean,
cv.Optional("tags", default=False): cv.boolean,
cv.Optional("long", default=False): cv.boolean,
cv.Optional("always", default=False): cv.boolean,
cv.Optional("abbrev"): cv.positive_int,
}
)
Expand Down Expand Up @@ -238,6 +239,8 @@ def produce_git_describe(config):
COMMAND.append("--tags")
if config.get("long", False):
COMMAND.append("--long")
if config.get("always", False):
COMMAND.append("--always")

if "abbrev" in config:
COMMAND.append(f"--abbrev={config['abbrev']}")
Expand Down