Skip to content

Commit

Permalink
Add scantags.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Sep 12, 2023
1 parent 3a28110 commit fe9255d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ jobs:
- name: test
run: |
make test
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: .
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ https://gitlab.com/gitlab-org/gitlab/-/issues/424503 opened
https://gitlab.suse.de/qac/container-release-bot/-/issues/7 opened Thu Sep 15 15:57:32 CEST 2022 Explore new schedule options
```

## scantags.sh

The script [scantags.sh](scantags.sh) can scan a locally cloned repository for tags

## Requirements

- Docker or Podman to run the Docker image.
Expand Down
45 changes: 45 additions & 0 deletions scantags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
#
# Scan a repo such as https://github.com/os-autoinst/os-autoinst-distri-opensuse for tags
#

if [[ $# -eq 0 || $# -gt 2 ]] ; then
echo "Usage: $0 REPODIR [/path/to/creds.json]" >&2
exit 1
fi

REPODIR="$1"
CREDS="${2:-"$HOME/creds.json"}"

IMAGE="${IMAGE:-registry.opensuse.org/home/rbranco/branches/devel/bci/tumbleweed/containerfile/bugme:latest}"
format="{{tag}} \t{{status}}\t{{url}}\t{{updated}}\t{{title}}"
format="$(echo -en "$format")"

command=(podman run --rm -v "$CREDS:$CREDS:ro" "$IMAGE" --creds "$CREDS" --format "$format")

set -eE

tmpfile="$(mktemp)"

cleanup() {
rm -f "$tmpfile"
}

trap cleanup ERR EXIT HUP INT QUIT TERM

cd "$REPODIR"

declare -A tags

while read -r file tag ; do
tags[$tag]+="$file "
done < <(find . -name \*.pm -exec grep -nEro -e '(bsc|poo|gh)#[0-9]+' -e 'gh#[^#]+#[0-9]+' {} + | sort -u | sed "s/:/ /")

"${command[@]}" "${!tags[@]}" > "$tmpfile" 2>&1

for tag in "${!tags[@]}" ; do
grep -m1 "^$tag " "$tmpfile"
for file in ${tags[$tag]} ; do
echo -e "\t$file"
done
done

0 comments on commit fe9255d

Please sign in to comment.