From 02491ca845d3ea0041a921aa7427ae70cba69fa6 Mon Sep 17 00:00:00 2001
From: David Ostrovsky <david@ostrovsky.org>
Date: Sat, 28 Sep 2019 12:12:47 +0200
Subject: [PATCH] Discontinue support for draft workflow

As of gerrit 2.15 and later, draft workflow is replaced with
work-in-progress and private workflow. See this CL: [1] and this
issue upstream: [2].

Even though support for draft worklfow was removed, the drafts magic
draft option was preserved, and is mapped to creation of the private
change when pushed first time, or creation of change edit on subsequent
pushes. These behaviour was alaways controvesial, but was kept in place
because 2 major Gerrit clients: repo and git-review were still
referencing drafts magic branch. In upcoming gerrit releases the support
for drafts magic branch option is discontinued, and thus removed from
both repo and git-review: [3].

[1] https://gerrit-review.googlesource.com/c/gerrit/+/97230
[2] https://crbug.com/gerrit/6880
[3] https://gerrit-review.googlesource.com/c/gerrit/+/238898

Sem-Ver: api-break
Change-Id: I08a590d42e1ebaa230da960cd192c0b1df528332
---
 doc/source/installation.rst | 2 --
 git-review.1                | 4 +---
 git_review/cmd.py           | 8 --------
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/doc/source/installation.rst b/doc/source/installation.rst
index 530f9bf5..0d5b9a7a 100644
--- a/doc/source/installation.rst
+++ b/doc/source/installation.rst
@@ -101,7 +101,5 @@ The name of the script is $action-review where action can be:
 
 * post - run at the end after the review was sent.
 
-* draft - run when in draft mode.
-
 If the script returns with an exit status different than zero, git-review will
 exit with the custom shell exit code ``71``.
diff --git a/git-review.1 b/git-review.1
index ecad1ab4..8f99a443 100644
--- a/git-review.1
+++ b/git-review.1
@@ -161,8 +161,6 @@ Indicate that you do, in fact, understand if you are submitting more than
 one patch.
 .It Fl v , Fl \-verbose
 Turns on more verbose output.
-.It Fl D , Fl \-draft
-Submit review as a draft. Requires Gerrit 2.3 or newer.
 .It Fl R , Fl \-no\-rebase
 Do not automatically perform a rebase before submitting the change to
 Gerrit.
@@ -178,7 +176,7 @@ Enable or disable a color output. Default is "auto".
 Same thing as \-\-color=never.
 .It Fl \-no\-custom\-script
 Do not run scripts, installed as hooks/{action}-review, where action
-is one of "pre", "draft", or "post".
+is one of "pre" or "post".
 .It Fl \-track
 Choose the branch to submit the change against (and, if
 rebasing, to rebase against) from the branch being tracked
diff --git a/git_review/cmd.py b/git_review/cmd.py
index 0bc7c219..aa8b82e5 100644
--- a/git_review/cmd.py
+++ b/git_review/cmd.py
@@ -1423,8 +1423,6 @@ review.
 
     parser.add_argument("--reviewers", nargs="+",
                         help="Add reviewers to uploaded patch sets.")
-    parser.add_argument("-D", "--draft", dest="draft", action="store_true",
-                        help="Submit review as a draft")
     parser.add_argument("-n", "--dry-run", dest="dry", action="store_true",
                         help="Don't actually submit the branch for review")
     parser.add_argument("-i", "--new-changeid", dest="regenerate",
@@ -1553,7 +1551,6 @@ review.
     parser.add_argument("branch", nargs="?")
 
     parser.set_defaults(dry=False,
-                        draft=False,
                         verbose=False,
                         update=False,
                         setup=False,
@@ -1661,11 +1658,6 @@ review.
 
     ref = "for"
 
-    if options.draft:
-        ref = "drafts"
-        if options.custom_script:
-            run_custom_script("draft")
-
     cmd = ("git push --no-follow-tags %s HEAD:refs/%s/%s" %
            (remote, ref, branch))
     push_options = []