|
| 1 | +#! /bin/sh |
| 2 | + |
| 3 | +if [ "$1" = "-n" ]; then |
| 4 | + dryrun=: |
| 5 | + shift |
| 6 | +fi |
| 7 | + |
| 8 | +for f; do |
| 9 | + [ -f $f ] || (echo "ERROR: $f: file not found"; exit 1) |
| 10 | + old_maint=$(yq -e '.data.maintainer' $f | awk '{print $1}') |
| 11 | + case $old_maint in |
| 12 | + # nonconformant renames |
| 13 | + ssg_virtualization) new_maint=rhel-sst-virtualization ;; |
| 14 | + sst_cloud_experience) new_maint=rhel-sst-cloudexperience ;; |
| 15 | + sst_insights) new_maint=rhel-sst-idm-insights ;; |
| 16 | + sst_rhel_lightspeed) new_maint=rhel-sst-lightspeed ;; |
| 17 | + sst_rhgs) new_maint=rhel-sst-rh-ceph-storage ;; |
| 18 | + # individuals instead of SSTs |
| 19 | + bakery|bstinson) new_maint=rhel-sst-program ;; |
| 20 | + jwboyer) new_maint=rhel-sst-rh-ceph-storage ;; |
| 21 | + kkeithle) new_maint=rhel-sst-rh-ceph-storage ;; |
| 22 | + plautrba) new_maint=rhel-sst-security-selinux ;; |
| 23 | + sgallagh) new_maint=rhel-sst-centos-stream ;; |
| 24 | + # typos or obsolete names |
| 25 | + sst_platform_storage) new_maint=rhel-sst-logical-storage ;; |
| 26 | + sst_virtualization_spice) new_maint=rhel-sst-virtualization ;; |
| 27 | + sst_window_management) new_maint=rhel-sst-display-window-management ;; |
| 28 | + # regular patterns |
| 29 | + ssg_*|sst_*) new_maint=rhel-${old_maint//_/-} ;; |
| 30 | + rhel-ssg-*|rhel-sst-*) new_maint=${old_maint} ;; |
| 31 | + *) echo "ERROR: $f: unknown maintainer: $old_maint" ; exit 2 ;; |
| 32 | + esac |
| 33 | + |
| 34 | +$dryrun env MAINT=${new_maint} yq -I 2 -i '.data.maintainer = strenv(MAINT)' $f |
| 35 | + |
| 36 | + d=${f%/*} |
| 37 | + b=${f##*/} |
| 38 | + [ $d != $f ] || d="." |
| 39 | + case $b in |
| 40 | + acg-level1-*) |
| 41 | + nf=$d/${new_maint}--$b |
| 42 | + ;; |
| 43 | + cee_support_unwanted.yaml) |
| 44 | + nf=$d/${new_maint}--unwanted.yaml |
| 45 | + ;; |
| 46 | + cee-support-workload.yaml) |
| 47 | + nf=$d/${new_maint}--all.yaml |
| 48 | + ;; |
| 49 | + eln_buildroot.yaml) |
| 50 | + nf=$d/${new_maint}--rpmautospec.yaml |
| 51 | + ;; |
| 52 | + mingw-pkg-config-exclusion.yaml) |
| 53 | + nf=$d/${new_maint}--mingw-pkg-config-unwanted.yaml |
| 54 | + ;; |
| 55 | + mingw-pkgs-exclusion.yaml) |
| 56 | + nf=$d/${new_maint}--mingw-unwanted.yaml |
| 57 | + ;; |
| 58 | + rhel-8-appstream-comps-performance.yaml) |
| 59 | + nf=$d/${new_maint}--performance.yaml |
| 60 | + ;; |
| 61 | + ssg_*-*|sst_*-*) |
| 62 | + pfx=${b%%-*} |
| 63 | + sfx=${b#*-} |
| 64 | + [ "$pfx" = "$old_maint" ] || (echo "WARNING: $f: maintainer mismatch: $old_maint") |
| 65 | + nf=$d/${new_maint}--$sfx |
| 66 | + ;; |
| 67 | + sst_*) |
| 68 | + pfx=${b%.yaml} |
| 69 | + [ "$pfx" = "$old_maint" ] || (echo "WARNING: $f: maintainer mismatch: $old_maint") |
| 70 | + nf=$d/${new_maint}--all.yaml |
| 71 | + ;; |
| 72 | + rhel-ssg-*--*|rhel-sst-*--*) |
| 73 | + pfx=${b%%--*} |
| 74 | + sfx=${b#*--} |
| 75 | + [ "$pfx" = "$old_maint" ] || (echo "WARNING: $f: maintainer mismatch: $old_maint") |
| 76 | + nf=$d/${new_maint}--$sfx |
| 77 | + ;; |
| 78 | + *) echo "ERROR: $f: unknown filename pattern: $f" ; exit 3 ;; |
| 79 | + esac |
| 80 | + |
| 81 | + if [ "$nf" != "$f" ]; then |
| 82 | + echo "$f ($old_maint) -> $nf ($new_maint)" |
| 83 | + $dryrun git mv $f $nf || (echo "ERROR: rename of $f to $nf failed"; exit 4) |
| 84 | + fi |
| 85 | +done |
0 commit comments