summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-02-20 09:06:23 +0100
committerGitHub <noreply@github.com>2020-02-20 09:06:23 +0100
commite8f0921d164c4b7db78e2f62e75eb32094b4456e (patch)
treed603f98235d9bfb6b1968a4e3412bb0d8efe72ba /tools
parent19242c398b9074e04e35cc687c31c543a10db280 (diff)
parentcb436951b1fde9c010e966819c75d0d7adacf17d (diff)
downloadgitlab-e8f0921d164c4b7db78e2f62e75eb32094b4456e.tar.gz
Merge pull request #1020 from nejch/feat/revert-commit-api
feat: add support for commit revert API (#991)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/cli_test_v4.sh9
-rw-r--r--tools/python_test_v4.py15
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/cli_test_v4.sh b/tools/cli_test_v4.sh
index dc6e0b2..b7ed708 100755
--- a/tools/cli_test_v4.sh
+++ b/tools/cli_test_v4.sh
@@ -100,6 +100,15 @@ testcase "merge request validation" '
--iid "$MR_ID" >/dev/null 2>&1
'
+# Test revert commit
+COMMITS=$(GITLAB -v project-commit list --project-id "${PROJECT_ID}")
+COMMIT_ID=$(pecho "${COMMITS}" | grep -m1 '^id:' | cut -d' ' -f2)
+
+testcase "revert commit" '
+ GITLAB project-commit revert --project-id "$PROJECT_ID" \
+ --id "$COMMIT_ID" --branch master
+'
+
# Test project labels
testcase "create project label" '
OUTPUT=$(GITLAB -v project-label create --project-id $PROJECT_ID \
diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py
index bffdd2a..49f99e5 100644
--- a/tools/python_test_v4.py
+++ b/tools/python_test_v4.py
@@ -462,6 +462,21 @@ d_note_from_get.delete()
discussion = commit.discussions.get(discussion.id)
# assert len(discussion.attributes["notes"]) == 1
+# Revert commit
+revert_commit = commit.revert(branch="master")
+
+expected_message = 'Revert "{}"\n\nThis reverts commit {}'.format(
+ commit.message, commit.id
+)
+assert revert_commit["message"] == expected_message
+
+try:
+ commit.revert(branch="master")
+ # Only here to really ensure expected error without a full test framework
+ raise AssertionError("Two revert attempts should raise GitlabRevertError")
+except gitlab.GitlabRevertError:
+ pass
+
# housekeeping
admin_project.housekeeping()