gerrit/contrib/mitm-ui/force-version.py
Viktar Donich 508f81ddce Scripts for UI plugins development using mitmproxy
Starts a local proxy that rewrites prod server responses, adding new
plugins, serving local files, enabling or disabling assets bundles.

Prerequisite: Docker
Target platform: OS X

Change-Id: I9abd94c816f987bf43e4335aff5be7ad17dd0fde
2018-12-21 15:22:16 -08:00

23 lines
740 B
Python

# mitmdump -q -p 8888 -s "force-version.py --version $1"
# Request URL is not changed, only the response context
from mitmproxy import http
import argparse
import re
class Server:
def __init__(self, version):
self.version = version
def request(self, flow: http.HTTPFlow) -> None:
if "gr-app." in flow.request.pretty_url:
flow.request.url = re.sub(
r"polygerrit_ui/([\d.]+)/elements",
"polygerrit_ui/" + self.version + "/elements",
flow.request.url)
def start():
parser = argparse.ArgumentParser()
parser.add_argument("--version", type=str, help="Rapid release version, e.g. 432.0")
args = parser.parse_args()
return Server(args.version)