fix "Could not update local clone for ... command line ... is prohibited on this...
[teamcity/git-plugin.git] / git-server-tc / src / jetbrains / buildServer / buildTriggers / vcs / git / GitClonesUpdater.java
index 004cf68c6c9d11289a6e0cc7b1704a754d5e68e6..4435f5988be95a83c37544d0d4df171d41dda159 100644 (file)
 package jetbrains.buildServer.buildTriggers.vcs.git;
 
 import jetbrains.buildServer.log.Loggers;
 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;
 import jetbrains.buildServer.util.EventDispatcher;
 import jetbrains.buildServer.util.ThreadUtil;
 import jetbrains.buildServer.util.executors.ExecutorsFactory;
@@ -54,7 +51,7 @@ public class GitClonesUpdater {
                                          @NotNull final RepositoryState newState) {
         if (serverResponsibility.canCheckForChanges()) return;
 
                                          @NotNull final RepositoryState newState) {
         if (serverResponsibility.canCheckForChanges()) return;
 
-        if (!TeamCityProperties.getBoolean("teamcity.git.localClones.updateIfNoCheckingForChangesResponsibility")) return;
+        if (!TeamCityProperties.getBooleanOrTrue("teamcity.git.localClones.updateIfNoCheckingForChangesResponsibility")) return;
 
         if (root.getVcsName().equals(Constants.VCS_NAME)) {
           myScheduledForUpdate.put(root, RepositoryStateFactory.toData(newState));
 
         if (root.getVcsName().equals(Constants.VCS_NAME)) {
           myScheduledForUpdate.put(root, RepositoryStateFactory.toData(newState));
@@ -87,14 +84,16 @@ public class GitClonesUpdater {
 
       OperationContext context = myVcs.createContext(root, "updating local clone");
       try {
 
       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);
         });
       } catch (VcsException e1) {
         Loggers.VCS.warnAndDebugDetails("Could not update local clone for: " + LogUtil.describe(root), e1);