Merge "Fire missing onGitReferenceUpdated events"

This commit is contained in:
Martin Fick 2015-11-11 18:57:42 +00:00 committed by Gerrit Code Review
commit 35882c9b9f
3 changed files with 20 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.NoSuchProjectException;
@ -52,6 +53,7 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
}
private final ChangeHooks hooks;
private final GitReferenceUpdated gitRefUpdated;
private final IdentifiedUser user;
private final ProjectAccessFactory.Factory projectAccessFactory;
private final ProjectCache projectCache;
@ -63,7 +65,9 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
MetaDataUpdate.User metaDataUpdateFactory,
AllProjectsNameProvider allProjects,
Provider<SetParent> setParent,
ChangeHooks hooks, IdentifiedUser user,
ChangeHooks hooks,
GitReferenceUpdated gitRefUpdated,
IdentifiedUser user,
@Assisted("projectName") Project.NameKey projectName,
@Nullable @Assisted ObjectId base,
@Assisted List<AccessSection> sectionList,
@ -75,6 +79,7 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
this.projectAccessFactory = projectAccessFactory;
this.projectCache = projectCache;
this.hooks = hooks;
this.gitRefUpdated = gitRefUpdated;
this.user = user;
}
@ -84,6 +89,8 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
throws IOException, NoSuchProjectException, ConfigInvalidException {
RevCommit commit = config.commit(md);
gitRefUpdated.fire(config.getProject().getNameKey(), RefNames.REFS_CONFIG,
base, commit.getId());
hooks.doRefUpdatedHook(
new Branch.NameKey(config.getProject().getNameKey(), RefNames.REFS_CONFIG),
base, commit.getId(), user.getAccount());

View File

@ -36,6 +36,7 @@ import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.config.ProjectConfigEntry;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
@ -89,6 +90,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
private final DynamicMap<RestView<ProjectResource>> views;
private final Provider<CurrentUser> user;
private final ChangeHooks hooks;
private final GitReferenceUpdated gitRefUpdated;
@Inject
PutConfig(@EnableSignedPush boolean serverEnableSignedPush,
@ -102,6 +104,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
AllProjectsNameProvider allProjects,
DynamicMap<RestView<ProjectResource>> views,
ChangeHooks hooks,
GitReferenceUpdated gitRefUpdated,
Provider<CurrentUser> user) {
this.serverEnableSignedPush = serverEnableSignedPush;
this.metaDataUpdateFactory = metaDataUpdateFactory;
@ -114,6 +117,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
this.allProjects = allProjects;
this.views = views;
this.hooks = hooks;
this.gitRefUpdated = gitRefUpdated;
this.user = user;
}
@ -199,6 +203,8 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
ObjectId commitRev = projectConfig.commit(md);
// Only fire hook if project was actually changed.
if (!Objects.equals(baseRev, commitRev)) {
gitRefUpdated.fire(projectName, RefNames.REFS_CONFIG,
baseRev, commitRev);
hooks.doRefUpdatedHook(
new Branch.NameKey(projectName, RefNames.REFS_CONFIG),
baseRev, commitRev, user.get().asIdentifiedUser().getAccount());

View File

@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
@ -46,15 +47,18 @@ public class PutDescription implements RestModifyView<ProjectResource, PutDescri
private final MetaDataUpdate.Server updateFactory;
private final GitRepositoryManager gitMgr;
private final ChangeHooks hooks;
private final GitReferenceUpdated gitRefUpdated;
@Inject
PutDescription(ProjectCache cache,
MetaDataUpdate.Server updateFactory,
ChangeHooks hooks,
GitReferenceUpdated gitRefUpdated,
GitRepositoryManager gitMgr) {
this.cache = cache;
this.updateFactory = updateFactory;
this.hooks = hooks;
this.gitRefUpdated = gitRefUpdated;
this.gitMgr = gitMgr;
}
@ -91,6 +95,8 @@ public class PutDescription implements RestModifyView<ProjectResource, PutDescri
ObjectId commitRev = config.commit(md);
// Only fire hook if project was actually changed.
if (!Objects.equals(baseRev, commitRev)) {
gitRefUpdated.fire(resource.getNameKey(), RefNames.REFS_CONFIG,
baseRev, commitRev);
hooks.doRefUpdatedHook(
new Branch.NameKey(resource.getNameKey(), RefNames.REFS_CONFIG),
baseRev, commitRev, user.getAccount());