Merge branch 'stable-2.11' * stable-2.11: Add force-draft argument description Remove unused imports Build with API version 2.11.5 Build with API version 2.11.4 Build with API version 2.11 Change-Id: I383d3d3db172dbf6d737062afaecd0c7bceb09ce
diff --git a/.buckconfig b/.buckconfig new file mode 100644 index 0000000..65bac24 --- /dev/null +++ b/.buckconfig
@@ -0,0 +1,14 @@ +[alias] + force-draft = //:force-draft + plugin = //:force-draft + +[java] + src_roots = java, resources + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d71845 --- /dev/null +++ b/.gitignore
@@ -0,0 +1,7 @@ +/.buckd +/.buckversion +/.classpath +/.project +/.watchmanconfig +/buck-out/ +/bucklets
diff --git a/BUCK b/BUCK index 93830e2..3af58c7 100644 --- a/BUCK +++ b/BUCK
@@ -1,3 +1,5 @@ +include_defs('//bucklets/gerrit_plugin.bucklet') + gerrit_plugin( name = 'force-draft', srcs = glob(['src/main/java/**/*.java']), @@ -5,5 +7,12 @@ manifest_entries = [ 'Gerrit-PluginName: force-draft', 'Gerrit-SshModule: com.googlesource.gerrit.plugins.forcedraft.ForceDraftSshModule', + 'Implementation-Title: Force draft plugin', + 'Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/force-draft', ] ) + +java_library( + name = 'classpath', + deps = GERRIT_PLUGIN_API + [':force-draft__plugin'], +)
diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..25ebda2 --- /dev/null +++ b/VERSION
@@ -0,0 +1,3 @@ +# Maven style API version (e.g. '2.x-SNAPSHOT'). +# +PLUGIN_VERSION = '2.12-SNAPSHOT'
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK new file mode 100644 index 0000000..bb14be3 --- /dev/null +++ b/lib/gerrit/BUCK
@@ -0,0 +1,13 @@ +include_defs('//bucklets/maven_jar.bucklet') + +VER = '2.12-SNAPSHOT' +REPO = MAVEN_LOCAL + +maven_jar( + name = 'plugin-api', + id = 'com.google.gerrit:gerrit-plugin-api:' + VER, + license = 'Apache2.0', + attach_source = False, + repository = REPO, +) +
diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 59090a5..0000000 --- a/pom.xml +++ /dev/null
@@ -1,85 +0,0 @@ -<?xml version="1.0"?> -<!-- -Copyright (C) 2013 The Android Open Source Project - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> -<project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" - xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - - <artifactId>force-draft</artifactId> - <name>force-draft</name> - <groupId>com.googlesource.gerrit.plugins.forcedraft</groupId> - <packaging>jar</packaging> - <version>2.11.5</version> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <Gerrit-ApiType>plugin</Gerrit-ApiType> - <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.4</version> - <configuration> - <archive> - <manifestEntries> - <Gerrit-PluginName>${project.name}</Gerrit-PluginName> - <Implementation-Title>Plugin ${project.name}</Implementation-Title> - <Implementation-Version>${project.version}</Implementation-Version> - <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> - <Implementation-Vendor-URL>http://code.google.com/p/gerrit/</Implementation-Vendor-URL> - <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> - <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> - <Gerrit-SshModule>com.googlesource.gerrit.plugins.forcedraft.ForceDraftSshModule</Gerrit-SshModule> - </manifestEntries> - </archive> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.2</version> - <configuration> - <source>1.6</source> - <target>1.6</target> - <encoding>UTF-8</encoding> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>com.google.gerrit</groupId> - <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> - <version>${Gerrit-ApiVersion}</version> - <scope>provided</scope> - </dependency> - </dependencies> - - <repositories> - <repository> - <id>gerrit-api-repository</id> - <url>https://gerrit-api.commondatastorage.googleapis.com/release/</url> - </repository> - </repositories> - -</project>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/forcedraft/ForceDraftSshModule.java b/src/main/java/com/googlesource/gerrit/plugins/forcedraft/ForceDraftSshModule.java index 1870336..5936b6a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/forcedraft/ForceDraftSshModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/forcedraft/ForceDraftSshModule.java
@@ -13,12 +13,15 @@ // limitations under the License. package com.googlesource.gerrit.plugins.forcedraft; -import com.google.gerrit.sshd.PluginCommandModule; +import com.google.gerrit.sshd.SingleCommandPluginModule; +import com.google.inject.binder.LinkedBindingBuilder; -public class ForceDraftSshModule extends PluginCommandModule { +import org.apache.sshd.server.Command; + +public class ForceDraftSshModule extends SingleCommandPluginModule { @Override - protected void configureCommands() { - command(ForceDraft.class); + protected void configure(LinkedBindingBuilder<Command> bind) { + bind.to(ForceDraft.class); } }
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..55aa534 --- /dev/null +++ b/src/main/resources/Documentation/about.md
@@ -0,0 +1,2 @@ +This plugin provides an ssh-command that changes the status of +a patchset to draft to enable patchset deletion by owner.
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md new file mode 100644 index 0000000..1086a18 --- /dev/null +++ b/src/main/resources/Documentation/build.md
@@ -0,0 +1,79 @@ +Build +===== + +This @PLUGIN@ plugin is built with Buck. + +Two build modes are supported: Standalone and in Gerrit tree. +The standalone build mode is recommended, as this mode doesn't require +the Gerrit tree to exist locally. + +#### Build standalone + +Clone bucklets library: + +``` + git clone https://gerrit.googlesource.com/bucklets + +``` +and link it to @PLUGIN@ plugin directory: + +``` + cd @PLUGIN@ && ln -s ../bucklets . +``` + +Add link to the .buckversion file: + +``` + cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion +``` + +Add link to the .watchmanconfig file: + +``` + cd @PLUGIN@ && ln -s bucklets/watchmanconfig .watchmanconfig +``` + +To build the plugin, issue the following command: + +``` + buck build plugin +``` + +The output is created in + +``` + buck-out/gen/@PLUGIN@.jar +``` + +This project can be imported into the Eclipse IDE: + +``` + ./bucklets/tools/eclipse.py +``` + +#### Build in Gerrit tree + +Clone or link this plugin to the plugins directory of Gerrit's source +tree, and issue the command: + +``` + buck build plugins/@PLUGIN@ +``` + +in the root of Gerrit's source tree to build + +The output is created in + +``` + buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar +``` + +This project can be imported into the Eclipse IDE: + +``` + ./tools/eclipse/project.py +``` + +[Back to @PLUGIN@ documentation index][index] + +[index]: index.html
diff --git a/src/main/resources/Documentation/cmd-force-draft.md b/src/main/resources/Documentation/cmd-force-draft.md new file mode 100644 index 0000000..97e77c8 --- /dev/null +++ b/src/main/resources/Documentation/cmd-force-draft.md
@@ -0,0 +1,33 @@ +@PLUGIN@ +============== + +NAME +---- +@PLUGIN@ - Force patchset to draft. + +SYNOPSIS +-------- +``` +ssh -p @SSH_PORT@ @SSH_HOST@ @PLUGIN@ <Change, Patchset> +``` + +DESCRIPTION +----------- +Forces specified patchset to 'draft' state in order to help +administrators enable users to remove unwanted patchsets themselves. +If all patchsets of a change are set to 'draft', the change is also set +to 'draft'. +Since this command only sets the patchset, or patchset and change, to +'draft' state, the actual deletion is performed by the user leaving the +administrators free from responsibility. + +ACCESS +------ +Caller must be a member of the privileged 'Administrators' group. + +EXAMPLES +-------- +Change status of patchset 3 of change 1234 to 'draft': +``` +ssh -p @SSH_PORT@ @SSH_HOST@ @PLUGIN@ 1234,3 +```
diff --git a/src/main/resources/documentation/about.md b/src/main/resources/documentation/about.md deleted file mode 100644 index ec07db1..0000000 --- a/src/main/resources/documentation/about.md +++ /dev/null
@@ -1,11 +0,0 @@ -This plugin enables admin-user to easily change PatchSet to draft. - -Sometimes Git-administrators are forced to remove PatchSets for legal, -or other reason. Today this is done by setting the PatchSet as Draft in db. -This procedure is troublesome and error-prone due to the human -factor. -This plugin enables administrators to perform the procedure with a simple -ssh-command. - -If all PatchSets of parent change are drafts, parent Change is -also set to draft.