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 fcd3984
Show file tree
Hide file tree
Showing 2 changed files with 55 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: .
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 -Ero -e '(bsc|poo|gh)#[0-9]+' -e 'gh#[^#]+#[0-9]+' {} + | sort -u | awk -F: '{ print $1, $2 }')

"${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 fcd3984

Please sign in to comment.