From 2a268d777c7f45c77f494102619d5f0ebda42d07 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 30 Jun 2022 12:16:30 +0200 Subject: [PATCH] [IMP] forwardport: check commit liveness on the PR we're porting from Check remains a tad dodgy, but since we're actually porting from `root` (the earliest ancestor of `self`) it makes more sense to sanity-check that *its* commits remain visible. Also log that as it makes a tad more sense, hopefully. Closes #600 --- forwardport/models/project.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/forwardport/models/project.py b/forwardport/models/project.py index 3c2742ab..ee099c3a 100644 --- a/forwardport/models/project.py +++ b/forwardport/models/project.py @@ -806,6 +806,7 @@ This PR targets %s and is part of the forward-port chain. Further PRs will be cr :rtype: (None | (str, str, str, list[str]), Repo) """ source = self._get_local_directory() + root = self._get_root() # update all the branches & PRs r = source.with_params('gc.pruneExpire=1.day.ago')\ .with_config( @@ -814,17 +815,16 @@ This PR targets %s and is part of the forward-port chain. Further PRs will be cr )\ .fetch('-p', 'origin') _logger.info("Updated %s:\n%s", source._directory, r.stdout.decode()) - # FIXME: check that pr.head is pull/{number}'s head instead? - source.cat_file(e=self.head) + source.cat_file(e=root.head) # create working copy - _logger.info("Create working copy to forward-port %s:%d to %s", - self.repository.name, self.number, target_branch.name) + _logger.info( + "Create working copy to forward-port %s (really %s) to %s", + self.display_name, root.display_name, target_branch.name) working_copy = source.clone( cleanup.enter_context( tempfile.TemporaryDirectory( - prefix='%s:%d-to-%s-' % ( - self.repository.name, - self.number, + prefix='%s-to-%s-' % ( + root.display_name, target_branch.name ), dir=user_cache_dir('forwardport') @@ -843,7 +843,6 @@ This PR targets %s and is part of the forward-port chain. Further PRs will be cr _logger.info("Create FP branch %s", fp_branch_name) working_copy.checkout(b=fp_branch_name) - root = self._get_root() try: root._cherry_pick(working_copy) return None, working_copy