tor-browser

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

restore_elm_arcconfig.py (2056B)


      1 #!/bin/env python
      2 # This Source Code Form is subject to the terms of the Mozilla Public
      3 # License, v. 2.0. If a copy of the MPL was not distributed with this
      4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      5 
      6 
      7 import atexit
      8 import os
      9 import sys
     10 
     11 from run_operations import (
     12    ErrorHelp,
     13    RepoType,
     14    detect_repo_type,
     15    run_git,
     16    run_shell,
     17 )
     18 
     19 script_name = os.path.basename(__file__)
     20 error_help = ErrorHelp()
     21 error_help.set_prefix(f"*** ERROR *** {script_name} did not complete successfully")
     22 repo_type = detect_repo_type()
     23 
     24 
     25 @atexit.register
     26 def early_exit_handler():
     27    error_help.print_help()
     28 
     29 
     30 # This script sets the Arcanist configuration for the elm repo. This script
     31 # should be run after each repository reset.
     32 #
     33 # Usage: from the root of the repo `./mach python dom/media/webrtc/third_party_build/restore_elm_arcconfig.py`
     34 #
     35 
     36 # first, check which repo we're in, git or hg
     37 if repo_type is None or not isinstance(repo_type, RepoType):
     38    print("Unable to detect repo (git or hg)")
     39    sys.exit(1)
     40 
     41 commit_msg = "Bug 1729988 - FLOAT - REPO-elm - update .arcconfig repo callsign r=bgrins"
     42 arc_config_file = "dom/media/webrtc/third_party_build/elm_arcconfig.patch"
     43 
     44 error_help.set_help("Failed to add FLOATing arcconfig patch for ELM")
     45 
     46 if repo_type == RepoType.GIT:
     47    run_git(f"git apply {arc_config_file}", ".")
     48    run_git("git add .arcconfig", ".")
     49    # use run_shell to avoid run_git's call to split on the cmd string
     50    run_shell(f'git commit -m "{commit_msg}" .arcconfig')
     51 else:
     52    # use run_shell to avoid run_hg's call to split on the cmd string
     53    run_shell(f"hg import -m '{commit_msg}' {arc_config_file}")
     54 
     55 print("ELM .arcconfig restored. Please push this change to ELM:")
     56 if repo_type == RepoType.GIT:
     57    # this command may change when we can test this on the official
     58    # twig repo as hosted on git.
     59    print("    git push origin master")
     60 else:
     61    print("    hg push -r tip")
     62 
     63 # unregister the exit handler so the normal exit doesn't falsely
     64 # report as an error.
     65 atexit.unregister(early_exit_handler)