summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-06-04 14:28:14 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-06-04 20:18:21 +0000
commit8842cb5337c78b934e8da7752a9f23d36a671a1f (patch)
treefd60a97cf1df679b0fd3614977961b0cbc4e1a59
parent75bb0b6cd12959618f91e11a8f69b1a0af04bb41 (diff)
Improve special_case_helper.py
Make sure to set the author user and email for the temporary git repo, so that the commits succeed on systems that don't have a global git author. Also fix run_process_quiet to print stderr and stdout in case if the execution failed for some reason. Change-Id: I0ddb61730114b3e9c59e2d23480df0ced8d6e772 Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com> Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--util/cmake/special_case_helper.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/util/cmake/special_case_helper.py b/util/cmake/special_case_helper.py
index 8777b9c4db..57b91b6cb1 100644
--- a/util/cmake/special_case_helper.py
+++ b/util/cmake/special_case_helper.py
@@ -146,7 +146,13 @@ def run_process_quiet(args_string: str, debug=False) -> None:
if debug:
print('Running command: "{}\"'.format(args_string))
args_list = args_string.split()
- subprocess.run(args_list, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ try:
+ subprocess.run(args_list, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ # git merge with conflicts returns with exit code 1, but that's not
+ # an error for us.
+ if 'git merge' not in args_string:
+ print('Error while running: "{}"\n{}'.format(args_string, e.stdout))
def does_file_have_conflict_markers(file_path: str, debug=False) -> bool:
@@ -228,19 +234,23 @@ class SpecialCaseHandler(object):
try:
# Create new repo with the "clean" CMakeLists.txt file.
run_process_quiet('git init .', debug=self.debug)
+ run_process_quiet('git config user.name fake', debug=self.debug)
+ run_process_quiet('git config user.email fake@fake', debug=self.debug)
copyfile_log(no_special_cases_file_path, txt, debug=self.debug)
run_process_quiet('git add {}'.format(txt), debug=self.debug)
run_process_quiet('git commit -m no_special', debug=self.debug)
+ run_process_quiet('git checkout -b no_special', debug=self.debug)
# Copy the original "modified" file (with the special cases)
# and make a new commit.
+ run_process_quiet('git checkout -b original', debug=self.debug)
copyfile_log(original_file_path, txt, debug=self.debug)
run_process_quiet('git add {}'.format(txt), debug=self.debug)
run_process_quiet('git commit -m original', debug=self.debug)
# Checkout the commit with "clean" file again, and create a
# new branch.
- run_process_quiet('git checkout HEAD~', debug=self.debug)
+ run_process_quiet('git checkout no_special', debug=self.debug)
run_process_quiet('git checkout -b newly_generated', debug=self.debug)
# Copy the new "modified" file and make a commit.
@@ -250,7 +260,7 @@ class SpecialCaseHandler(object):
# Merge the "old" branch with modifications into the "new"
# branch with the newly generated file.
- run_process_quiet('git merge master', debug=self.debug)
+ run_process_quiet('git merge original', debug=self.debug)
# Resolve some simple conflicts (just remove the markers)
# for cases that don't need intervention.