Plugin API for change and revision
Change [1] started to implement new API with RevisionApi.review. This change implements the following API methods: * abandon * rebase * restore * revert * submit * delete (draft) SSH review command was migrated to utilize the new API. Acceptance tests were added for the new API methods. [1] https://gerrit-review.googlesource.com/48664 Change-Id: I2240759ba64401d0760c72490b9f4d05f965ecfc
This commit is contained in:
committed by
Shawn Pearce
parent
72d5b01b47
commit
44a1930ebf
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
|
||||
public class AbandonInput {
|
||||
@DefaultInput
|
||||
public String message;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,18 @@ package com.google.gerrit.extensions.api.changes;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
public interface ChangeApi {
|
||||
String id();
|
||||
|
||||
RevisionApi current() throws RestApiException;
|
||||
RevisionApi revision(int id) throws RestApiException;
|
||||
RevisionApi revision(String id) throws RestApiException;
|
||||
|
||||
void abandon() throws RestApiException;
|
||||
void abandon(AbandonInput in) throws RestApiException;
|
||||
|
||||
void restore() throws RestApiException;
|
||||
void restore(RestoreInput in) throws RestApiException;
|
||||
|
||||
ChangeApi revert() throws RestApiException;
|
||||
ChangeApi revert(RevertInput in) throws RestApiException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
|
||||
public class RestoreInput {
|
||||
@DefaultInput
|
||||
public String message;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
|
||||
public class RevertInput {
|
||||
@DefaultInput
|
||||
public String message;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -85,4 +86,31 @@ public class ReviewInput {
|
||||
public int endCharacter;
|
||||
}
|
||||
}
|
||||
|
||||
public ReviewInput message(String msg) {
|
||||
message = msg != null && !msg.isEmpty() ? msg : null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReviewInput label(String name, short value) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (labels == null) {
|
||||
labels = new LinkedHashMap<String, Short>(4);
|
||||
}
|
||||
labels.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReviewInput label(String name, int value) {
|
||||
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return label(name, (short) value);
|
||||
}
|
||||
|
||||
public ReviewInput label(String name) {
|
||||
return label(name, (short) 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,11 @@ package com.google.gerrit.extensions.api.changes;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
public interface RevisionApi {
|
||||
void delete() throws RestApiException;
|
||||
void rebase() throws RestApiException;
|
||||
void review(ReviewInput in) throws RestApiException;
|
||||
|
||||
/** {@code submit} with {@link SubmitInput#waitForMerge} set to true. */
|
||||
void submit() throws RestApiException;
|
||||
void submit(SubmitInput in) throws RestApiException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
public class SubmitInput {
|
||||
public boolean waitForMerge;
|
||||
}
|
||||
Reference in New Issue
Block a user