Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

648: git sync requires ssh to be specified when setting 'to' repo on set-up #827

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/main/java/org/openjdk/skara/cli/GitSync.java
Expand Up @@ -170,7 +170,7 @@ static void sync(Repository repo, String[] args) throws IOException, Interrupted
}

var fromPullPath = remotes.contains(from) ?
Remote.toURI(repo.pullPath(from)) : URI.create(from);
Remote.toURI(repo.pullPath(from)) : Remote.toURI(from);

String to = null;
if (arguments.contains("to")) {
Expand All @@ -193,7 +193,7 @@ static void sync(Repository repo, String[] args) throws IOException, Interrupted
}

var toPushPath = remotes.contains(to) ?
Remote.toURI(repo.pullPath(to)) : URI.create(to);
Remote.toURI(repo.pullPath(to)) : Remote.toURI(to);

var toScheme = toPushPath.getScheme();
if (toScheme.equals("https") || toScheme.equals("http")) {
Expand Down
6 changes: 5 additions & 1 deletion cli/src/main/java/org/openjdk/skara/cli/Remote.java
Expand Up @@ -85,6 +85,10 @@ public static URI toWebURI(String remotePath) throws IOException {
}

public static URI toURI(String remotePath) throws IOException {
return toURI(remotePath, false);
}

public static URI toURI(String remotePath, boolean canonicalize) throws IOException {
if (remotePath.startsWith("git+")) {
remotePath = remotePath.substring("git+".length());
}
Expand All @@ -101,7 +105,7 @@ public static URI toURI(String remotePath) throws IOException {
if (indexOfColon != -1) {
if (indexOfSlash == -1 || indexOfColon < indexOfSlash) {
var uri = URI.create("ssh://" + remotePath.replace(":", "/"));
return sshCanonicalize(uri);
return canonicalize ? sshCanonicalize(uri) : uri;
}
}

Expand Down