From 245497deafcb5d554694e0084291f70b45f1a724 Mon Sep 17 00:00:00 2001 From: Mikhail Atuchin Date: Wed, 21 Aug 2024 13:49:10 +0700 Subject: [PATCH 1/2] Fetch the target branch automatically --- seed/fieldtrials_testing_config_generator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/seed/fieldtrials_testing_config_generator.py b/seed/fieldtrials_testing_config_generator.py index 50bc9053..054e4b21 100644 --- a/seed/fieldtrials_testing_config_generator.py +++ b/seed/fieldtrials_testing_config_generator.py @@ -49,10 +49,12 @@ NPM_EXECUTABLE = 'npm.cmd' if sys.platform == 'win32' else 'npm' def _get_variations_revision(date: str, branch: str) -> str: - args = ['git', 'rev-list', '-n', '1', '--first-parent'] + # fetch the branch: + subprocess.check_call(['git', 'fetch', 'origin', branch]) + + args = ['git', 'rev-list', 'FETCH_HEAD', '-n', '1', '--first-parent'] if date: args.append(f'--before={date}') - args.append(branch) output = subprocess.check_output(args) return output.rstrip().decode('utf-8') @@ -207,9 +209,9 @@ def main(): if args.use_current_branch: branch = 'HEAD' elif date < PRODUCTION_BRANCH_MIGRATION_DATE: - branch = 'origin/production-archive' + branch = 'production-archive' else: - branch = 'origin/main' + branch = 'main' revision = _get_variations_revision(args.target_date, branch) print('Load seed at', revision, 'from branch', branch) From 65970d0afba5ba40532dee57cf3ae2e419c2ddb2 Mon Sep 17 00:00:00 2001 From: Mikhail Atuchin Date: Thu, 22 Aug 2024 18:50:46 +0700 Subject: [PATCH 2/2] Make exclusion for HEAD --- seed/fieldtrials_testing_config_generator.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/seed/fieldtrials_testing_config_generator.py b/seed/fieldtrials_testing_config_generator.py index 054e4b21..cdc8beda 100644 --- a/seed/fieldtrials_testing_config_generator.py +++ b/seed/fieldtrials_testing_config_generator.py @@ -207,14 +207,16 @@ def main(): target_unix_time = date.timestamp() if args.use_current_branch: - branch = 'HEAD' - elif date < PRODUCTION_BRANCH_MIGRATION_DATE: - branch = 'production-archive' + revision = 'HEAD' + print('Load seed from HEAD') else: - branch = 'main' + if date < PRODUCTION_BRANCH_MIGRATION_DATE: + branch = 'production-archive' + else: + branch = 'main' + revision = _get_variations_revision(args.target_date, branch) + print('Load seed at', revision, 'from branch', branch) - revision = _get_variations_revision(args.target_date, branch) - print('Load seed at', revision, 'from branch', branch) seed_message = _get_variations_seed(revision) if args.output_revision is not None: