commit 20c39d120a6b3a50a0895d32d9606307edfd59d1 parent 5fb5d7992bba987990f561b0ba53ce6dda0c978e Author: Michael Froman <mjfroman@mac.com> Date: Wed, 17 Dec 2025 18:33:49 +0000 Bug 2004467 - add git support to commit-build-file-changes.sh r=dbaker DONTBUILD Differential Revision: https://phabricator.services.mozilla.com/D275309 Diffstat:
| M | dom/media/webrtc/third_party_build/commit-build-file-changes.sh | | | 69 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- |
1 file changed, 56 insertions(+), 13 deletions(-)
diff --git a/dom/media/webrtc/third_party_build/commit-build-file-changes.sh b/dom/media/webrtc/third_party_build/commit-build-file-changes.sh @@ -10,6 +10,8 @@ ERROR_HELP="" # Print an Error message if `set -eE` causes the script to exit due to a failed command trap 'show_error_msg $LINENO' ERR +source dom/media/webrtc/third_party_build/use_config_env.sh + if [ "x$PROCESS_DIR" = "x" ]; then PROCESS_DIR=third_party/libwebrtc echo "Default directory: $PROCESS_DIR" @@ -24,34 +26,75 @@ fi # * o pipefail: All stages of all pipes should succede. set -eEuo pipefail +find_repo_type +echo "repo type: $MOZ_REPO" + if [ ! -d $PROCESS_DIR ]; then echo "No directory found for '$PROCESS_DIR'" exit 1 fi -MOZ_BUILD_CHANGE_CNT=`hg status --include="**moz.build" $PROCESS_DIR | wc -l | tr -d " "` +if [ "x$MOZ_REPO" == "xgit" ]; then + BUILD_FILE_GIT_SPEC="$PROCESS_DIR/**moz.build" + MOZ_BUILD_CHANGE_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | wc -l | tr -d " "` +else + MOZ_BUILD_CHANGE_CNT=`hg status --include="**moz.build" $PROCESS_DIR | wc -l | tr -d " "` +fi echo "MOZ_BUILD_CHANGE_CNT: $MOZ_BUILD_CHANGE_CNT" if [ "x$MOZ_BUILD_CHANGE_CNT" != "x0" ]; then - CURRENT_COMMIT_SHA=`hg id -i | sed 's/+//'` - COMMIT_DESC=`hg --config alias.log=log log -T '{desc|firstline}' -r $CURRENT_COMMIT_SHA` + if [ "x$MOZ_REPO" == "xgit" ]; then + COMMIT_DESC=`git show --format='%s' --no-patch` + else + CURRENT_COMMIT_SHA=`hg id -i | sed 's/+//'` + COMMIT_DESC=`hg --config alias.log=log log -T '{desc|firstline}' -r $CURRENT_COMMIT_SHA` + fi # since we have build file changes, touch the CLOBBER file - cat CLOBBER | egrep "^#|^$" > CLOBBER.new + cat CLOBBER | grep -E "^#|^$" > CLOBBER.new mv CLOBBER.new CLOBBER echo "Modified build files in $PROCESS_DIR - $COMMIT_DESC" >> CLOBBER - ADD_CNT=`hg status --include="**moz.build" -nu $PROCESS_DIR | wc -l | tr -d " "` - DEL_CNT=`hg status --include="**moz.build" -nd $PROCESS_DIR | wc -l | tr -d " "` - if [ "x$ADD_CNT" != "x0" ]; then - hg status --include="**moz.build" -nu $PROCESS_DIR | xargs hg add + # handle added files + if [ "x$MOZ_REPO" == "xgit" ]; then + ADD_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^??" | wc -l | tr -d " " || true` + if [ "x$ADD_CNT" != "x0" ]; then + git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^??" | awk '{ print $2; }' | xargs git add + fi + else + ADD_CNT=`hg status --include="**moz.build" -nu $PROCESS_DIR | wc -l | tr -d " "` + if [ "x$ADD_CNT" != "x0" ]; then + hg status --include="**moz.build" -nu $PROCESS_DIR | xargs hg add + fi fi - if [ "x$DEL_CNT" != "x0" ]; then - hg status --include="**moz.build" -nd $PROCESS_DIR | xargs hg rm + + # handle deleted files + if [ "x$MOZ_REPO" == "xgit" ]; then + DEL_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^ D" | wc -l | tr -d " " || true` + if [ "x$DEL_CNT" != "x0" ]; then + git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^ D" | awk '{ print $2; }' | xargs git rm --quiet + fi + else + DEL_CNT=`hg status --include="**moz.build" -nd $PROCESS_DIR | wc -l | tr -d " "` + if [ "x$DEL_CNT" != "x0" ]; then + hg status --include="**moz.build" -nd $PROCESS_DIR | xargs hg rm + fi + fi + + # handle modified files - mercurial doesn't need this + if [ "x$MOZ_REPO" == "xgit" ]; then + MOD_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" CLOBBER | grep "^ M" | wc -l | tr -d " " || true` + if [ "x$MOD_CNT" != "x0" ]; then + git status --porcelain "$BUILD_FILE_GIT_SPEC" CLOBBER | grep "^ M" | awk '{ print $2; }' | xargs git add + fi fi - hg commit -m \ - "$COMMIT_DESC - moz.build file updates" \ - --include="**moz.build" --include="CLOBBER" $PROCESS_DIR CLOBBER + if [ "x$MOZ_REPO" == "xgit" ]; then + git commit -m "$COMMIT_DESC - moz.build file updates" + else + hg commit -m \ + "$COMMIT_DESC - moz.build file updates" \ + --include="**moz.build" --include="CLOBBER" $PROCESS_DIR CLOBBER + fi fi echo "Done in $0"