fix "Could not update local clone for ... command line ... is prohibited on this...
authorPavel Sher <pavel.sher@jetbrains.com>
Mon, 21 Jan 2019 15:45:03 +0000 (16:45 +0100)
committerPavel Sher <pavel.sher@jetbrains.com>
Mon, 21 Jan 2019 15:45:49 +0000 (16:45 +0100)
wrap operation to make sure we are always able to update local clones on secondary node

git-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/git/GitClonesUpdater.java

index 452a66655bc83faa8484151f3ad59b2baabc95d2..4435f5988be95a83c37544d0d4df171d41dda159 100644 (file)
 package jetbrains.buildServer.buildTriggers.vcs.git;
 
 import jetbrains.buildServer.log.Loggers;
-import jetbrains.buildServer.serverSide.BuildServerAdapter;
-import jetbrains.buildServer.serverSide.BuildServerListener;
-import jetbrains.buildServer.serverSide.ServerResponsibility;
-import jetbrains.buildServer.serverSide.TeamCityProperties;
+import jetbrains.buildServer.serverSide.*;
 import jetbrains.buildServer.util.EventDispatcher;
 import jetbrains.buildServer.util.ThreadUtil;
 import jetbrains.buildServer.util.executors.ExecutorsFactory;
@@ -87,14 +84,16 @@ public class GitClonesUpdater {
 
       OperationContext context = myVcs.createContext(root, "updating local clone");
       try {
-        GitVcsRoot gitRoot = context.getGitRoot();
-        myRepositoryManager.runWithDisabledRemove(gitRoot.getRepositoryDir(), () -> {
-          Repository repo = context.getRepository();
-          try {
-            myVcs.getCollectChangesPolicy().ensureRepositoryStateLoadedFor(context, repo, true, state);
-          } catch (Exception e1) {
-            throw new VcsException(e1);
-          }
+        ReadOnlyRestrictor.doReadOnlyCommandLine(() -> {
+          GitVcsRoot gitRoot = context.getGitRoot();
+          myRepositoryManager.runWithDisabledRemove(gitRoot.getRepositoryDir(), () -> {
+            Repository repo = context.getRepository();
+            try {
+              myVcs.getCollectChangesPolicy().ensureRepositoryStateLoadedFor(context, repo, true, state);
+            } catch (Exception e1) {
+              throw new VcsException(e1);
+            }
+          });
         });
       } catch (VcsException e1) {
         Loggers.VCS.warnAndDebugDetails("Could not update local clone for: " + LogUtil.describe(root), e1);