tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

detect_upstream_revert.sh (3696B)


      1 #!/bin/bash
      2 
      3 function show_error_msg()
      4 {
      5  echo "*** ERROR *** $? line $1 $0 did not complete successfully!"
      6  echo "$ERROR_HELP"
      7 }
      8 ERROR_HELP=""
      9 
     10 # Print an Error message if `set -eE` causes the script to exit due to a failed command
     11 trap 'show_error_msg $LINENO' ERR
     12 
     13 source dom/media/webrtc/third_party_build/use_config_env.sh
     14 
     15 # If DEBUG_GEN is set all commands should be printed as they are executed
     16 if [ ! "x$DEBUG_GEN" = "x" ]; then
     17  set -x
     18 fi
     19 
     20 if [ "x$MOZ_LIBWEBRTC_SRC" = "x" ]; then
     21  echo "MOZ_LIBWEBRTC_SRC is not defined, see README.md"
     22  exit
     23 fi
     24 
     25 if [ -d $MOZ_LIBWEBRTC_SRC ]; then
     26  echo "MOZ_LIBWEBRTC_SRC is $MOZ_LIBWEBRTC_SRC"
     27 else
     28  echo "Path $MOZ_LIBWEBRTC_SRC is not found, see README.md"
     29  exit
     30 fi
     31 
     32 if [ "x$MOZ_LIBWEBRTC_BRANCH" = "x" ]; then
     33  echo "MOZ_LIBWEBRTC_BRANCH is not defined, see README.md"
     34  exit
     35 fi
     36 
     37 if [ "x$AUTO_FIX_REVERT_AS_NOOP" = "x" ]; then
     38  AUTO_FIX_REVERT_AS_NOOP="0"
     39 fi
     40 
     41 find_base_commit
     42 find_next_commit
     43 
     44 MOZ_LIBWEBRTC_COMMIT_MSG=`cd $MOZ_LIBWEBRTC_SRC ; \
     45 git show --name-only --oneline $MOZ_LIBWEBRTC_NEXT_BASE \
     46 | head -1 | sed 's/[^ ]* //'`
     47 
     48 echo "MOZ_LIBWEBRTC_BASE: $MOZ_LIBWEBRTC_BASE"
     49 echo "MOZ_LIBWEBRTC_NEXT_BASE: $MOZ_LIBWEBRTC_NEXT_BASE"
     50 echo "MOZ_LIBWEBRTC_COMMIT_MSG: $MOZ_LIBWEBRTC_COMMIT_MSG"
     51 export MOZ_LIBWEBRTC_REVERT_SHA=`cd $MOZ_LIBWEBRTC_SRC ; \
     52 git log --oneline -r $MOZ_LIBWEBRTC_BASE..$MOZ_TARGET_UPSTREAM_BRANCH_HEAD \
     53 | grep -F "Revert \"$MOZ_LIBWEBRTC_COMMIT_MSG" \
     54 | tail -1 | awk '{print $1;}' || true`
     55 
     56 if [ "x$MOZ_LIBWEBRTC_REVERT_SHA" == "x" ]; then
     57  echo "no revert commit summary detected in newer commits matching $MOZ_LIBWEBRTC_COMMIT_MSG"
     58  exit
     59 fi
     60 
     61 echo "found potential MOZ_LIBWEBRTC_REVERT_SHA: $MOZ_LIBWEBRTC_REVERT_SHA"
     62 echo "checking commit message for 'This reverts commit' to confirm"
     63 CONFIRM_SHA=`cd $MOZ_LIBWEBRTC_SRC ; \
     64 git show $MOZ_LIBWEBRTC_REVERT_SHA \
     65 | awk '/This reverts commit/ { print $NF; }' \
     66 | tr -d '[:punct:]'`
     67 
     68 if [ "x$CONFIRM_SHA" == "x" ]; then
     69  echo "no revert commit listed in commit message for $MOZ_LIBWEBRTC_REVERT_SHA"
     70  exit
     71 fi
     72 
     73 # convert to short sha
     74 CONFIRM_SHA=`cd $MOZ_LIBWEBRTC_SRC ; \
     75 git show --format='%h' --no-patch $CONFIRM_SHA`
     76 
     77 if [ $MOZ_LIBWEBRTC_NEXT_BASE != $CONFIRM_SHA ]; then
     78  echo "revert sha ($MOZ_LIBWEBRTC_NEXT_BASE) does not match commit listed in commit summary ($CONFIRM_SHA)"
     79  exit
     80 fi
     81 
     82 
     83 if [ "x$AUTO_FIX_REVERT_AS_NOOP" = "x1" ]; then
     84  echo "AUTO_FIX_REVERT_AS_NOOP detected, fixing land/revert pair automatically"
     85  bash $SCRIPT_DIR/make_upstream_revert_noop.sh
     86  exit
     87 fi
     88 
     89 echo $"
     90 The next upstream commit has a corresponding future \"Revert\" commit.
     91 
     92 There are 2 common ways forward in this situation:
     93 1. If you're relatively certain there will not be rebase conflicts in the
     94   github repo ($MOZ_LIBWEBRTC_SRC), simply run:
     95       SKIP_NEXT_REVERT_CHK=1 bash $SCRIPT_DIR/loop-ff.sh
     96 
     97 2. The surer method for no rebase conflicts is to cherry-pick both the
     98   next commit, and the commit that reverts the next commit onto the
     99   bottom of our patch stack in github.  This pushes the likely rebase
    100   conflict into the future when the upstream fix is relanded, but
    101   ensures we only have to deal with the conflict once.  The following
    102   commands will add the necessary commits to the bottom of our patch
    103   stack in github, and leave indicator files in the home directory that
    104   help loop-ff know when to invoke special no-op commit handling:
    105 
    106       MOZ_LIBWEBRTC_BASE=$MOZ_LIBWEBRTC_BASE \\
    107       MOZ_LIBWEBRTC_NEXT_BASE=$MOZ_LIBWEBRTC_NEXT_BASE \\
    108       MOZ_LIBWEBRTC_REVERT_SHA=$MOZ_LIBWEBRTC_REVERT_SHA \\
    109       bash $SCRIPT_DIR/make_upstream_revert_noop.sh
    110 
    111       SKIP_NEXT_REVERT_CHK=1 bash $SCRIPT_DIR/loop-ff.sh
    112 "
    113 exit 1