diff options
author | Hector Oswaldo Caballero <hector.caballero@ericsson.com> | 2015-12-16 15:01:12 -0500 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-18 08:07:21 +0000 |
commit | 173494bb65cd8bf6c73a4bdcb0947090522896ed (patch) | |
tree | 8172b3e21ac19713f0b5dc237143157c67cc5a74 | |
parent | 577892c8dc4181cd70928f8e64bdcf2490ca44b4 (diff) |
Replicate HEAD reference when replicating a project
Replication plugin replicates HEAD changes to target instances giving
such changes are done using the web UI. If for any reason the target
instance was down when doing such change, or if the change was manually
done (either by editing the HEAD file directly or using a git command),
this HEAD change was not propagated and the target instance kept the
outdated head. Pushing manual replication did not replicate HEAD to
targets, and thus, the HEAD reference had to be manually updated on the
target instance.
Replicate HEAD reference when replicating a project so that HEAD changes
are always replicated to target instances, either when replication is
triggered automatically or when it is done using the 'replication start'
ssh command.
Change-Id: Ibd9be085dd56bf80a27e2798513fd06592209704
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java | 6 | ||||
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java index 255c51b..36e3ecb 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java @@ -372,6 +372,7 @@ class PushOne implements ProjectRunnable { PushResult res; try { res = pushVia(tn); + updateHead(); } finally { try { tn.close(); @@ -545,6 +546,11 @@ class PushOne implements ProjectRunnable { cmds.add(new RemoteRefUpdate(git, (Ref) null, dst, force, null, null)); } + private void updateHead() throws IOException { + replicationQueue.updateHead(projectName, git.getRef(Constants.HEAD) + .getTarget().getName()); + } + private void updateStates(Collection<RemoteRefUpdate> refUpdates) throws LockFailureException { Set<String> doneRefs = new HashSet<>(); diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java index 95693d9..c3b4675 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java @@ -163,9 +163,13 @@ class ReplicationQueue implements @Override public void onHeadUpdated(HeadUpdatedListener.Event event) { - for (URIish uri : getURIs(new Project.NameKey(event.getProjectName()), - FilterType.ALL)) { - updateHead(uri, event.getNewHeadName()); + updateHead(new Project.NameKey(event.getProjectName()), + event.getNewHeadName()); + } + + void updateHead(Project.NameKey project, String newHeadName) { + for (URIish uri : getURIs(project, FilterType.ALL)) { + updateHead(uri, newHeadName); } } |