Skip to content

Commit

Permalink
Fetch the target branch automatically in fieldtrials_testing_config_g…
Browse files Browse the repository at this point in the history
…enerator.py (#1192)

`fieldtrials_testing_config_generator.py` now automatically updates the
target branch.
This cover that case when the branch wasn't fetch or is outdated.
  • Loading branch information
atuchin-m authored Aug 22, 2024
1 parent a86855b commit 9a56ae8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions seed/fieldtrials_testing_config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -205,14 +207,16 @@ def main():
target_unix_time = date.timestamp()

if args.use_current_branch:
branch = 'HEAD'
elif date < PRODUCTION_BRANCH_MIGRATION_DATE:
branch = 'origin/production-archive'
revision = 'HEAD'
print('Load seed from HEAD')
else:
branch = 'origin/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:
Expand Down

0 comments on commit 9a56ae8

Please sign in to comment.