mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix GitHttpAdapter#isHttpUrl and rename to make more descriptive.
Add a test.
This commit is contained in:
@@ -82,7 +82,7 @@ public class GitPull extends GitRepositoryAction {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GitHttpAdapter.isHttpUrlWithoutUserCredentials(url)) {
|
||||
if (GitHttpAdapter.shouldUseJGit(url)) {
|
||||
boolean fetchSuccessful = new GitFetcher(project, indicator).fetchRootsAndNotify(gitRoots, "Push failed", false);
|
||||
if (!fetchSuccessful) {
|
||||
return;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class GitCheckoutProvider implements CheckoutProvider {
|
||||
}
|
||||
|
||||
private static boolean doClone(@NotNull Project project, @NotNull String directoryName, @NotNull String parentDirectory, @NotNull String sourceRepositoryURL) {
|
||||
if (GitHttpAdapter.isHttpUrlWithoutUserCredentials(sourceRepositoryURL)) {
|
||||
if (GitHttpAdapter.shouldUseJGit(sourceRepositoryURL)) {
|
||||
GitFetchResult result = GitHttpAdapter.cloneRepository(project, new File(parentDirectory, directoryName), sourceRepositoryURL);
|
||||
GitFetcher.displayFetchResult(project, result, "Clone failed", result.getErrors());
|
||||
return result.isSuccess();
|
||||
|
||||
@@ -141,7 +141,7 @@ public class GitCloneDialog extends DialogWrapper {
|
||||
|
||||
private void test() {
|
||||
myTestURL = getCurrentUrlText();
|
||||
boolean testResult = GitHttpAdapter.isHttpUrlWithoutUserCredentials(myTestURL) ? testHttp(myTestURL) : testNatively(myTestURL);
|
||||
boolean testResult = GitHttpAdapter.shouldUseJGit(myTestURL) ? testHttp(myTestURL) : testNatively(myTestURL);
|
||||
|
||||
if (testResult) {
|
||||
Messages.showInfoMessage(myTestButton, GitBundle.message("clone.test.success.message", myTestURL),
|
||||
|
||||
@@ -65,11 +65,11 @@ public final class GitHttpAdapter {
|
||||
|
||||
private static final Pattern HTTP_URL_WITH_USERNAME_AND_PASSWORD = Pattern.compile("http(s?)://([^\\s^@:]+):([^\\s^@:]+)@.*");
|
||||
|
||||
public static boolean isHttpUrlWithoutUserCredentials(@NotNull String url) {
|
||||
// if username & password are specified in the url, give it to the native Git
|
||||
public static boolean shouldUseJGit(@NotNull String url) {
|
||||
if (!url.startsWith("http")) {
|
||||
return false;
|
||||
}
|
||||
// if username & password are specified in the url, give it to the native Git
|
||||
if (HTTP_URL_WITH_USERNAME_AND_PASSWORD.matcher(url).matches()) {
|
||||
return false;
|
||||
}
|
||||
@@ -79,11 +79,11 @@ public final class GitHttpAdapter {
|
||||
return !netrcData.hasAuthDataForUrl(url);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn("Couldn't read netrc file", e);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class GitPullDialog extends DialogWrapper {
|
||||
|
||||
@NotNull
|
||||
private Collection<String> getRemoteBranches(@NotNull GitDeprecatedRemote remote) {
|
||||
if (GitHttpAdapter.isHttpUrlWithoutUserCredentials(remote.fetchUrl())) {
|
||||
if (GitHttpAdapter.shouldUseJGit(remote.fetchUrl())) {
|
||||
GitRepository repository = GitRepositoryManager.getInstance(myProject).getRepositoryForRoot(gitRoot());
|
||||
if (repository == null) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -332,7 +332,7 @@ public final class GitPusher {
|
||||
return pushNatively(repository, pushSpec);
|
||||
}
|
||||
else {
|
||||
return GitHttpAdapter.isHttpUrlWithoutUserCredentials(remoteUrl) ? GitHttpAdapter.push(repository, null, remoteUrl, null) : pushNatively(repository, pushSpec);
|
||||
return GitHttpAdapter.shouldUseJGit(remoteUrl) ? GitHttpAdapter.push(repository, null, remoteUrl, null) : pushNatively(repository, pushSpec);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -340,7 +340,7 @@ public final class GitPusher {
|
||||
assert remote != null : "Remote can't be null for pushSpec " + pushSpec;
|
||||
String httpUrl = null;
|
||||
for (String pushUrl : remote.getPushUrls()) {
|
||||
if (GitHttpAdapter.isHttpUrlWithoutUserCredentials(pushUrl)) {
|
||||
if (GitHttpAdapter.shouldUseJGit(pushUrl)) {
|
||||
httpUrl = pushUrl;
|
||||
break; // TODO support http and ssh urls in one origin
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class GitFetcher {
|
||||
if (url == null) {
|
||||
continue;
|
||||
}
|
||||
if (GitHttpAdapter.isHttpUrlWithoutUserCredentials(url)) {
|
||||
if (GitHttpAdapter.shouldUseJGit(url)) {
|
||||
GitFetchResult res = GitHttpAdapter.fetch(repository, remote, url);
|
||||
myErrors.addAll(res.getErrors());
|
||||
if (!res.isSuccess()) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
MACHine BITBUCKET.org
|
||||
password pass
|
||||
LOGIN john
|
||||
@@ -0,0 +1 @@
|
||||
n7 uppercase, login & password order change
|
||||
@@ -0,0 +1 @@
|
||||
bitbucket.org john pass
|
||||
Reference in New Issue
Block a user