Created
June 3, 2021 22:30
-
-
Save thesamesam/ed773ac26d823d1287ee3bd65b4919ca to your computer and use it in GitHub Desktop.
Bash script to commit all changes per-Gentoo-package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Name: commit-changed-pkgs | |
## Description: | |
## Commits all changes with a given template | |
## Can exclude by maintainer. | |
## Useful for e.g. big batch changes like a sed across tree | |
## Usage: | |
## - bash ~/scripts/commit-changed-pkgs | |
## Configuration: | |
## - maintainers: maintainers to skip | |
## - template: file containing "*: msg" or "cat/pkg: msg" respectively for pkgdev/repoman | |
## - tool: pkgdev or repoman | |
## - debug: noisy or not | |
#maintainers="(project1|project2) | |
maintainers="" | |
template="~/scripts/template-repoman" | |
tool="repoman" | |
debug=1 | |
# | |
# Get a list of the files changed | |
list=$(git diff --name-only | grep -v "/layout/" | grep -v "/metadata/") | |
# Parse out the directories to make it easier to see metadata.xml | |
dirs=() | |
for file in ${list[@]} ; do | |
dirs+=($(dirname "${file}")) | |
done | |
# Mangle the format for iteration | |
dirs=($(echo ${dirs[@]} | tr ' ' '\n' | sort -u)) | |
# Iterate over all of the files changed locally (unstaged) | |
# If any ebuilds are in a directory mentioning a maintainer | |
# we want to skip, we don't stage the changes. | |
for dir in ${dirs[@]} ; do | |
if [[ ${dir} == *eclass* ]] || [[ ${dir} == *metadata* ]] ; then | |
continue | |
fi | |
if ! [[ -z ${maintainers} ]] ; then | |
egrep -qe "${maintainers}" "${dir}"/metadata.xml | |
if [[ $? -eq 0 ]] ; then | |
[[ ${debug} -eq 1 ]] && echo "Skipping ${dir}"; | |
continue | |
fi | |
fi | |
dir=${dir/files/} | |
cd "${dir}" | |
git add . | |
${tool} commit -M ${template} | |
cd ../.. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment