diff options
author | Max Hohenegger | 2015-11-10 00:53:41 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-11-23 00:02:43 +0000 |
commit | 211bb85b48481e7bc7f4242c33b7d177da91b7e2 (patch) | |
tree | 1e898853dc274545a2077e46a5a01cb308454115 | |
parent | 25cfe1c0b4d3fca62594b13777898bdf871e6e3f (diff) | |
download | egit-211bb85b48481e7bc7f4242c33b7d177da91b7e2.tar.gz egit-211bb85b48481e7bc7f4242c33b7d177da91b7e2.tar.xz egit-211bb85b48481e7bc7f4242c33b7d177da91b7e2.zip |
Fix 'GitFlow doesn't use configured timeout for remote git commands'
- added timeout parameter to API
- deprecated existing API
Bug: 481553
Change-Id: I3a69bc9f5dea0c1fa81f9c672d1c7e1421a27c4e
Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 files changed, 50 insertions, 7 deletions
diff --git a/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/FeatureTrackOperationTest.java b/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/FeatureTrackOperationTest.java index 47cee9fcc1..b8590cba3a 100644 --- a/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/FeatureTrackOperationTest.java +++ b/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/FeatureTrackOperationTest.java @@ -21,6 +21,8 @@ import org.eclipse.jgit.transport.FetchResult; import org.junit.Test; public class FeatureTrackOperationTest extends AbstractDualRepositoryTestCase { + private static final int NO_TIMEOUT = 0; + @Test public void testFeatureTrack() throws Exception { GitFlowRepository gfRepo1 = new GitFlowRepository( @@ -32,7 +34,7 @@ public class FeatureTrackOperationTest extends AbstractDualRepositoryTestCase { .createInitialCommit("testFeatureTrack"); FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation( - gfRepo2, getFirstRemoteFeatureRef(gfRepo2)); + gfRepo2, getFirstRemoteFeatureRef(gfRepo2), NO_TIMEOUT); featureTrackOperation.execute(null); FetchResult operationResult = featureTrackOperation .getOperationResult(); diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/FeatureTrackHandler.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/FeatureTrackHandler.java index 3904b88c64..46726251ef 100644 --- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/FeatureTrackHandler.java +++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/FeatureTrackHandler.java @@ -92,7 +92,7 @@ public class FeatureTrackHandler extends AbstractHandler { Ref ref = dialog.getSelectedNode(); FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation( - gfRepo, ref); + gfRepo, ref, timeout); JobUtil.scheduleUserWorkspaceJob(featureTrackOperation, UIText.FeatureTrackHandler_trackingFeature, GITFLOW_FAMILY); diff --git a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureListOperation.java b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureListOperation.java index 40605c1525..5772d21b5b 100644 --- a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureListOperation.java +++ b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureListOperation.java @@ -58,7 +58,7 @@ public final class FeatureListOperation extends GitFlowOperation { String uriString = FILE + repository.getRepository().getDirectory().getPath(); try { - operationResult = fetch(monitor); + operationResult = fetch(monitor, timeout); URIish uri = new URIish(uriString); ListRemoteOperation listRemoteOperation = new ListRemoteOperation( diff --git a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureTrackOperation.java b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureTrackOperation.java index d3818eca02..52fb709b8f 100644 --- a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureTrackOperation.java +++ b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/FeatureTrackOperation.java @@ -42,16 +42,37 @@ public final class FeatureTrackOperation extends AbstractFeatureOperation { private FetchResult operationResult; + private int timeout; + /** * Track given ref, referencing a feature branch. * * @param repository * @param ref + * @deprecated Use + * {@link FeatureTrackOperation#FeatureTrackOperation(GitFlowRepository, Ref, int)} + * instead. */ + @Deprecated public FeatureTrackOperation(GitFlowRepository repository, Ref ref) { + this(repository, ref, 0); + } + + /** + * Track given ref, referencing a feature branch. + * + * @param repository + * @param ref + * @param timeout + * timeout in seconds for remote operations + * @since 4.2 + */ + public FeatureTrackOperation(GitFlowRepository repository, Ref ref, + int timeout) { this(repository, ref, ref.getName().substring( (REMOTE_ORIGIN_FEATURE_PREFIX + repository.getConfig() .getFeaturePrefix()).length())); + this.timeout = timeout; } /** @@ -72,7 +93,7 @@ public final class FeatureTrackOperation extends AbstractFeatureOperation { try { String newLocalBranch = repository .getConfig().getFeatureBranchName(featureName); - operationResult = fetch(monitor); + operationResult = fetch(monitor, timeout); if (repository.hasBranch(newLocalBranch)) { String errorMessage = String.format( diff --git a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/GitFlowOperation.java b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/GitFlowOperation.java index fdee6d6323..41648921ff 100644 --- a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/GitFlowOperation.java +++ b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/op/GitFlowOperation.java @@ -246,21 +246,41 @@ abstract public class GitFlowOperation implements IEGitOperation { } /** + * Fetch using the default remote configuration + * * @param monitor - * @return resulting of fetching from remote + * @param timeout + * timeout in seconds + * @return result of fetching from remote * @throws URISyntaxException * @throws InvocationTargetException + * + * @since 4.2 */ - protected FetchResult fetch(IProgressMonitor monitor) + protected FetchResult fetch(IProgressMonitor monitor, int timeout) throws URISyntaxException, InvocationTargetException { RemoteConfig config = repository.getConfig().getDefaultRemoteConfig(); FetchOperation fetchOperation = new FetchOperation( - repository.getRepository(), config, 0, false); + repository.getRepository(), config, timeout, false); fetchOperation.run(monitor); return fetchOperation.getOperationResult(); } /** + * @param monitor + * @return resulting of fetching from remote + * @throws URISyntaxException + * @throws InvocationTargetException + * @deprecated Use {@link GitFlowOperation#fetch(IProgressMonitor, int)} + * instead. + */ + @Deprecated + protected FetchResult fetch(IProgressMonitor monitor) + throws URISyntaxException, InvocationTargetException { + return fetch(monitor, 0); + } + + /** * @return The result of the merge this operation performs. May be null, if * no merge was performed. */ |