mirror of https://github.com/grafana/loki
Tools: add tool to determine which release (if any) a commit appears in (#8706)
I've often found myself needing to determine which release a particular
PR appears in. This tool makes that easy, and it accepts the merge
commit ref of the PR.
Example from https://github.com/grafana/loki/pull/7044, in which [a user
is asking which version this feature appears
in](https://github.com/grafana/loki/pull/7044#issuecomment-1455694087).
```bash
$ ./tools/which-release.sh 93a5a71
Commit was found in the following releases:
release-2.7.x
```
pull/8688/head^2
parent
656ad800fe
commit
6c0f3442cc
@ -0,0 +1,25 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
COMMIT=$1 |
||||
if [[ -z "${COMMIT}" ]]; then |
||||
echo "Usage: $0 <commit-ref>" |
||||
exit 2 |
||||
fi |
||||
|
||||
REMOTE=$(git remote -v | grep grafana/loki | awk '{print $1}' | head -n1) |
||||
if [[ -z "${REMOTE}" ]]; then |
||||
echo "Could not find remote for grafana/loki" |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "It is recommended that you run \`git fetch -ap ${REMOTE}\` to ensure you get a correct result." |
||||
|
||||
RELEASES=$(git branch -r --contains "${COMMIT}" | grep "${REMOTE}" | grep "/release-" | sed "s|${REMOTE}/||") |
||||
if [[ -z "${RELEASES}" ]]; then |
||||
echo "Commit was not found in any release" |
||||
exit 1 |
||||
fi |
||||
|
||||
|
||||
echo "Commit was found in the following releases:" |
||||
echo "${RELEASES}" |
Loading…
Reference in new issue