Skip to content

Commit dc16ae9

Browse files
committed
Adapt to new QueryProcess<T> on Gerrit master
ChangeQueryProcessor has now a different interface on Gerrit master and we need to inject it differently and query for changes using the ChangeData as actual type. Change-Id: I9b70f2fc4f19305aa21d0cc92cbeb2fb5a6703de
1 parent 963b5ef commit dc16ae9

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
import com.google.gerrit.server.project.ProjectControl;
4242
import com.google.gerrit.server.project.RefControl;
4343
import com.google.gerrit.server.query.QueryParseException;
44+
import com.google.gerrit.server.query.QueryProcessor;
45+
import com.google.gerrit.server.query.QueryResult;
4446
import com.google.gerrit.server.query.change.ChangeData;
4547
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
48+
import com.google.gerrit.server.query.change.ChangeQueryProcessor;
4649
import com.google.gerrit.server.query.change.InternalChangeQuery;
47-
import com.google.gerrit.server.query.change.QueryProcessor;
48-
import com.google.gerrit.server.query.change.QueryResult;
4950
import com.google.gwtorm.server.OrmException;
5051
import com.google.inject.Inject;
5152
import com.google.inject.Provider;
@@ -77,7 +78,7 @@ public class PullRequestCreateChange {
7778
private final GenericFactory userFactory;
7879
private final Provider<InternalChangeQuery> queryProvider;
7980
private final BatchUpdate.Factory updateFactory;
80-
private final QueryProcessor qp;
81+
private final QueryProcessor<ChangeData> qp;
8182
private final ChangeQueryBuilder changeQuery;
8283

8384
@Inject
@@ -87,7 +88,7 @@ public class PullRequestCreateChange {
8788
IdentifiedUser.GenericFactory userFactory,
8889
Provider<InternalChangeQuery> queryProvider,
8990
BatchUpdate.Factory batchUpdateFactory,
90-
QueryProcessor qp,
91+
ChangeQueryProcessor qp,
9192
ChangeQueryBuilder changeQuery) {
9293
this.changeInserterFactory = changeInserterFactory;
9394
this.patchSetInserterFactory = patchSetInserterFactory;
@@ -195,10 +196,10 @@ public Change.Id internalAddCommitToChange(ReviewDb db, BatchUpdate bu,
195196
}
196197

197198
private List<ChangeData> queryChangesForSha1(String pullRequestSha1) {
198-
QueryResult results;
199+
QueryResult<ChangeData> results;
199200
try {
200-
results = qp.queryChanges(changeQuery.commit(pullRequestSha1));
201-
return results.changes();
201+
results = qp.query(changeQuery.commit(pullRequestSha1));
202+
return results.entities();
202203
} catch (OrmException | QueryParseException e) {
203204
LOG.error("Invalid SHA1 " + pullRequestSha1
204205
+ ": cannot query changes for this pull request", e);

github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private void setAccountIdentity(IdentifiedUser user, HttpServletRequest req) thr
109109

110110
accountCache.evict(accountId);
111111
log.debug("Account cache evicted for {}", accountId);
112-
} catch (AccountException | OrmException e) {
112+
} catch (AccountException | OrmException | IOException e) {
113113
throw new ServletException("Cannot associate email '" + email
114114
+ "' to current user '" + user + "'", e);
115115
}

github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,22 @@
2323
import com.google.gerrit.server.git.GitRepositoryManager;
2424
import com.google.gerrit.server.project.ProjectCache;
2525
import com.google.gerrit.server.query.QueryParseException;
26+
import com.google.gerrit.server.query.QueryProcessor;
27+
import com.google.gerrit.server.query.change.ChangeData;
2628
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
27-
import com.google.gerrit.server.query.change.QueryProcessor;
29+
import com.google.gerrit.server.query.change.ChangeQueryProcessor;
2830
import com.google.gson.JsonArray;
2931
import com.google.gson.JsonObject;
3032
import com.google.gson.JsonPrimitive;
3133
import com.google.gwtorm.server.OrmException;
3234
import com.google.inject.Inject;
3335
import com.google.inject.Provider;
3436
import com.google.inject.Singleton;
35-
3637
import com.googlesource.gerrit.plugins.github.GitHubConfig;
3738
import com.googlesource.gerrit.plugins.github.oauth.GitHubLogin;
3839

3940
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
40-
import org.eclipse.jgit.errors.MissingObjectException;
41-
import org.eclipse.jgit.lib.ObjectId;
4241
import org.eclipse.jgit.lib.Repository;
43-
import org.eclipse.jgit.revwalk.RevWalk;
4442
import org.kohsuke.github.GHIssueState;
4543
import org.kohsuke.github.GHPullRequest;
4644
import org.kohsuke.github.GHPullRequestCommitDetail;
@@ -70,15 +68,15 @@ public class PullRequestListController implements VelocityController {
7068
private final ProjectCache projectsCache;
7169
private final GitRepositoryManager repoMgr;
7270
private final Provider<ReviewDb> schema;
73-
private final QueryProcessor qp;
71+
private final QueryProcessor<ChangeData> qp;
7472
private final ChangeQueryBuilder changeQuery;
7573

7674
@Inject
7775
public PullRequestListController(ProjectCache projectsCache,
7876
GitRepositoryManager repoMgr,
7977
Provider<ReviewDb> schema,
8078
GitHubConfig config,
81-
QueryProcessor qp,
79+
ChangeQueryProcessor qp,
8280
ChangeQueryBuilder changeQuery) {
8381
this.projectsCache = projectsCache;
8482
this.repoMgr = repoMgr;
@@ -203,8 +201,8 @@ private boolean isAnyCommitOfPullRequestToBeImported(ReviewDb db,
203201
for (GHPullRequestCommitDetail pullRequestCommit : ghPullRequest
204202
.listCommits()) {
205203
pullRequestToImport |=
206-
qp.queryChanges(changeQuery.commit(pullRequestCommit.getSha()))
207-
.changes().isEmpty();
204+
qp.query(changeQuery.commit(pullRequestCommit.getSha()))
205+
.entities().isEmpty();
208206
}
209207
return pullRequestToImport;
210208
} catch (OrmException | QueryParseException e) {

0 commit comments

Comments
 (0)