Merge "Use python for pre/post scripts"
This commit is contained in:
		| @@ -366,9 +366,9 @@ class BaseTestCase(testtools.TestCase): | |||||||
|         # ensure we execute within context of the git repository |         # ensure we execute within context of the git repository | ||||||
|         with DiveDir(self.testrepo.path): |         with DiveDir(self.testrepo.path): | ||||||
|             try: |             try: | ||||||
|                 output = subprocess.check_output(self.pre_script, |                 output = subprocess.check_output( | ||||||
|                                                  stderr=subprocess.STDOUT, |                     ["python", "-c", self.pre_script], | ||||||
|                                                  shell=True) |                     stderr=subprocess.STDOUT) | ||||||
|             except subprocess.CalledProcessError as e: |             except subprocess.CalledProcessError as e: | ||||||
|                 self.addDetail('pre-script-output', |                 self.addDetail('pre-script-output', | ||||||
|                                text_content(e.output.decode('utf-8'))) |                                text_content(e.output.decode('utf-8'))) | ||||||
| @@ -391,9 +391,9 @@ class BaseTestCase(testtools.TestCase): | |||||||
|         # ensure we execute within context of the git repository |         # ensure we execute within context of the git repository | ||||||
|         with DiveDir(self.testrepo.path): |         with DiveDir(self.testrepo.path): | ||||||
|             try: |             try: | ||||||
|                 output = subprocess.check_output(self.post_script, |                 output = subprocess.check_output( | ||||||
|                                                  stderr=subprocess.STDOUT, |                     ["python", "-c", self.post_script], | ||||||
|                                                  shell=True) |                     stderr=subprocess.STDOUT) | ||||||
|             except subprocess.CalledProcessError as e: |             except subprocess.CalledProcessError as e: | ||||||
|                 self.addDetail('post-script-output', |                 self.addDetail('post-script-output', | ||||||
|                                text_content(e.output.decode('utf-8'))) |                                text_content(e.output.decode('utf-8'))) | ||||||
|   | |||||||
| @@ -39,18 +39,34 @@ | |||||||
|   parser-args: [import, upstream/master] |   parser-args: [import, upstream/master] | ||||||
|  |  | ||||||
|   pre-script: | |   pre-script: | | ||||||
|     #!/bin/sh -e |     import os | ||||||
|  |  | ||||||
|     file_f=$(git diff --name-only upstream/master~1..upstream/master) |     from git_upstream.lib.pygitcompat import Repo | ||||||
|     git checkout master |  | ||||||
|     echo "hello world" > ${file_f} |  | ||||||
|     git add ${file_f} |     repo = Repo(os.path.curdir) | ||||||
|     git commit --amend --no-edit |     repo.git.checkout("master") | ||||||
|  |  | ||||||
|  |     conflict_file = repo.git.diff("upstream/master~1..upstream/master", | ||||||
|  |                                   name_only=True) | ||||||
|  |     with open(conflict_file, "w") as f: | ||||||
|  |         f.write("hello world") | ||||||
|  |  | ||||||
|  |     repo.git.add(conflict_file) | ||||||
|  |     repo.git.commit(amend=True, no_edit=True) | ||||||
|  |  | ||||||
|   post-script: | |   post-script: | | ||||||
|     #!/bin/sh -e |     import os | ||||||
|  |  | ||||||
|  |     from git_upstream.lib.pygitcompat import Repo | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     repo = Repo(os.path.curdir) | ||||||
|  |  | ||||||
|  |     conflict_file = repo.git.diff("upstream/master~1..upstream/master", | ||||||
|  |                                   name_only=True) | ||||||
|  |     repo.git.checkout("--ours", "--", conflict_file) | ||||||
|  |     repo.git.add(conflict_file) | ||||||
|  |     os.environ["GIT_EDITOR"] = "echo" | ||||||
|  |     repo.git.rebase("--continue") | ||||||
|  |  | ||||||
|     file_f=$(git diff --name-only upstream/master~1..upstream/master) |  | ||||||
|     git checkout --ours -- ${file_f} |  | ||||||
|     git add ${file_f} |  | ||||||
|     GIT_EDITOR=cat git rebase --continue |  | ||||||
|   | |||||||
| @@ -51,14 +51,19 @@ | |||||||
|   expected-changes: [B1, C1, F, G] |   expected-changes: [B1, C1, F, G] | ||||||
|  |  | ||||||
|   pre-script: | |   pre-script: | | ||||||
|     #!/bin/sh |     import os | ||||||
|  |  | ||||||
|  |     from git_upstream.lib.pygitcompat import Repo | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     repo = Repo(os.path.curdir) | ||||||
|  |     repo.git.checkout("master") | ||||||
|  |  | ||||||
|     # add a file with the same name as the SHA1 for node [C], which will |     # add a file with the same name as the SHA1 for node [C], which will | ||||||
|     # trigger an error unless the arguments are correct delimited from |     # trigger an error unless the arguments are correct delimited from | ||||||
|     # paths when the searcher lists commits |     # paths when the searcher lists commits | ||||||
|     git checkout master |     open(repo.git.log("-1", "HEAD~2", format="%H"), "w").close() | ||||||
|     touch $(git log -1 --format="%H" HEAD~2) |  | ||||||
|  |  | ||||||
|     # add one the same name as a merge-base commit which will be included in |     # add one the same name as a merge-base commit which will be included in | ||||||
|     # a rev-list of all or the merge-bases to ensure correct ordering. |     # a rev-list of all or the merge-bases to ensure correct ordering. | ||||||
|     touch $(git merge-base master upstream/master) |     open(repo.git.merge_base("master", "upstream/master"), "w").close() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins