feat: Autobuild changed build files from git commit

main
earnest ma 2021-10-06 18:38:35 -04:00
parent 3f23633dcc
commit 64e09d296d
Signed by: earnest ma
GPG Key ID: A343F43342EB6E2A
1 changed files with 20 additions and 0 deletions

20
aptpkg
View File

@ -15,6 +15,7 @@ Documentation: https://man.sr.ht/~earnestma/aptpkg
Usage: Usage:
aptpkg [directory] aptpkg [directory]
aptpkg --auto (commit id) Autobuild modified packages from commit
aptpkg -h, --help Show help aptpkg -h, --help Show help
EOF EOF
} }
@ -114,10 +115,29 @@ load_build(){
esac esac
} }
# Autobuild packages based on git list files changed in commit
# latest (HEAD) assumed if commit hash not provided
change_autobuild_pkgs(){
[ -d .git ] || error_usage_die "Current directory is not a git repository!"
commitid=$1
[ -n "$commitid" ] || commitid=HEAD
build_chg=$(git diff-tree --no-commit-id --name-only -r $commitid | grep "build" | sed 's#/build##')
echo "Using $commitid with files $build_chg"
for f in $build_chg; do
aptpkg "$f"
done
}
# Run! # Run!
case $1 in case $1 in
-h|--help) -h|--help)
show_help ;; show_help ;;
--auto)
shift
change_autobuild_pkgs "$1" ;;
*) *)
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
error_usage_die "You must provide one directory" error_usage_die "You must provide one directory"