This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/master' of ssh://mjanczarska@dev.eclipse.org…
…/gitroot/e4/org.eclipse.orion.server.git into HEAD
- Loading branch information
Showing
13 changed files
with
107 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 34 additions & 58 deletions
92
...ion.server.filesystem.git/src/org/eclipse/orion/internal/server/filesystem/git/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2010, 2011 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.orion.internal.server.filesystem.git; | ||
|
||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import org.eclipse.core.filesystem.IFileStore; | ||
import org.eclipse.jgit.lib.Repository; | ||
import org.eclipse.jgit.transport.Transport; | ||
import org.eclipse.jgit.transport.URIish; | ||
import org.eclipse.jgit.util.FS; | ||
import org.eclipse.orion.server.filesystem.git.GitFileStore; | ||
|
||
public class Utils { | ||
|
||
public static URIish toURIish(final URL u) throws URISyntaxException { | ||
String s = u.toString(); | ||
s = s.replace("?" + u.getQuery(), ""); // ignore query | ||
return new URIish(s); | ||
} | ||
|
||
public static boolean isValidRemote(GitFileStore gfs) { | ||
Transport transport = null; | ||
try { | ||
URIish remote = toURIish(gfs.getUrl()); | ||
Repository local = gfs.getLocalRepo(); | ||
if (!Transport.canHandleProtocol(remote, FS.DETECTED)) | ||
return false; | ||
transport = Transport.open(local, remote); | ||
transport.setCredentialsProvider(gfs.getCredentialsProvider()); | ||
transport.openFetch().close(); | ||
return true; | ||
} catch (Exception e) { | ||
// ignore and return false | ||
} finally { | ||
if (transport != null) | ||
transport.close(); | ||
} | ||
return false; | ||
} | ||
|
||
public static IFileStore getRoot(IFileStore gfs) { | ||
IFileStore parent = null; | ||
while ((parent = gfs.getParent()) != null) { | ||
gfs = parent; | ||
} | ||
return (IFileStore) gfs; | ||
} | ||
} | ||
/******************************************************************************* | ||
* Copyright (c) 2010, 2011 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.orion.internal.server.filesystem.git; | ||
|
||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import org.eclipse.core.filesystem.IFileStore; | ||
import org.eclipse.jgit.transport.URIish; | ||
|
||
public class Utils { | ||
|
||
public static URIish toURIish(final URL u) throws URISyntaxException { | ||
String s = u.toString(); | ||
s = s.replace("?" + u.getQuery(), ""); // ignore query | ||
return new URIish(s); | ||
} | ||
|
||
public static IFileStore getRoot(IFileStore gfs) { | ||
IFileStore parent = null; | ||
while ((parent = gfs.getParent()) != null) { | ||
gfs = parent; | ||
} | ||
return (IFileStore) gfs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.