Skip to content

Commit abf5d9e

Browse files
committed
Merge branch 'feature/git-ref' of github.com:jonpugh/goatscripts into feature/git-ref
2 parents e2dacaa + 00c8080 commit abf5d9e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/scripts.tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ jobs:
7575
- name: get current reference
7676
run: |
7777
git-ref
78+
git-ref --type
7879
REF=$(git-ref)
79-
echo "Current ref: $REF" >> $GITHUB_STEP_SUMMARY
80+
echo "Current ref: $REF $TYPE" >> $GITHUB_STEP_SUMMARY
8081
if [[ "$REF" != "${{ github.sha }}" ]]; then
8182
echo "Output of git-ref script ($REF) does not match github.sha (${{ github.sha }})"
8283
exit 1;

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
## Scripts
2121
- `run-with-summary`: Runs a command and generates a markdown summary with output and execution details.
2222
- `wait-for`: Runs a command repeatedly until it passes.
23+
- `git-ref`: Prints the branch or tag name of a git clone.
2324

2425
## Run With Summary
2526

@@ -96,6 +97,23 @@ wait-for curl https://deploy-url/ready
9697
# SILENT: Set to 1 to not print any output except the timeout exceeded error. Useful when running from other scripts. See wait-mysql
9798
```
9899
100+
## `git-ref`
101+
102+
> Print the branch or tag name of the current directory of a cloned git repo. Use `--type` to show if it is a branch or tag.
103+
104+
```
105+
git-ref [OPTIONS]
106+
107+
Prints the branch or tag of the current git repository.
108+
109+
Options:
110+
111+
-t, --type Print the git reference type ('branch' or 'tag').
112+
113+
If PWD is tracking a branch, print "branch".
114+
If PWD is in a DETACHED HEAD state, and there is a tag for the SHA, print "tag".
115+
If the PWD is in a DETACHED HEAD state, and there is no tag, exit with an error.
116+
```
99117
100118
## History
101119

0 commit comments

Comments
 (0)