Bug 1638136 [wpt PR 23617] - Clipboard API Tests: Move permissions tests to WPT....
[gecko.git] / gfx / angle / vendor_from_git.py
blobb92fd5f965419884819130ac5dc13489a00bb7e7
1 #! /usr/bin/env python3
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/.
6 assert __name__ != '__main__'
8 '''
9 Any time we vendor[1] from an external git repo, we want to keep a record of the csets
10 we're pulling from.
12 This script leaves a record of the merge-base reference tip and cherry-picks that we pull
13 into Gecko. (such as gfx/angle/cherry_picks.txt)
14 '''
16 from pathlib import *
17 import subprocess
18 import sys
20 # --
22 def print_now(*args):
23 print(*args)
24 sys.stdout.flush()
27 def run_checked(*args, **kwargs):
28 print(' ', args)
29 sys.stdout.flush()
30 return subprocess.run(args, check=True, **kwargs)
32 # --
34 def record_cherry_picks(dir_in_gecko, merge_base_origin):
35 # merge_base_origin is not always 'origin'!
36 merge_base_from = Path(dir_in_gecko, 'MERGE_BASE').read_text().split('\n')[0]
37 merge_base_from = merge_base_origin + '/' + merge_base_from
39 assert '/' in merge_base_from, 'Please specify a reference tip from a remote.'
40 log_path = Path(dir_in_gecko, 'cherry_picks.txt')
41 print_now('Logging cherry picks to {}.'.format(log_path))
43 merge_base = run_checked('git', 'merge-base', 'HEAD', merge_base_from,
44 stdout=subprocess.PIPE).stdout.decode().strip()
46 mb_info = run_checked('git', 'log', '{}~1..{}'.format(merge_base, merge_base),
47 stdout=subprocess.PIPE).stdout
48 cherries = run_checked('git', 'log', merge_base + '..', stdout=subprocess.PIPE).stdout
50 with open(log_path, 'wb') as f:
51 f.write(cherries)
52 f.write(b'\nCherries picked')
53 f.write(b'\n' + (b'=' * 80))
54 f.write(b'\nMerge base from: ' + merge_base_from.encode())
55 f.write(b'\n\n')
56 f.write(mb_info)