Skip to content
Permalink
Browse files
584: additional check for "git sync"
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Oct 22, 2020
1 parent 38f04d0 commit b56141b88bf90fa401b596d11bd822e5c21f7894
Showing with 14 additions and 0 deletions.
  1. +7 −0 cli/src/main/java/org/openjdk/skara/cli/GitSync.java
  2. +7 −0 cli/src/main/java/org/openjdk/skara/cli/Remote.java
@@ -201,6 +201,13 @@ static void sync(Repository repo, String[] args) throws IOException, Interrupted
var toPushPath = remotes.contains(to) ?
Remote.toURI(repo.pullPath(to)) : Remote.toURI(to);

var canonicalPushPath = Remote.toWebURI(Remote.canonicalize(toPushPath).toString());
var canonicalPullPath = Remote.toWebURI(Remote.canonicalize(fromPullPath).toString());
if (canonicalPushPath.equals(canonicalPullPath)) {
System.err.println("error: --from and --to refer to the same repository: " + canonicalPushPath.toString());
System.exit(1);
}

var toScheme = toPushPath.getScheme();
if (toScheme.equals("https") || toScheme.equals("http")) {
var token = System.getenv("GIT_TOKEN");
@@ -111,4 +111,11 @@ public static URI toURI(String remotePath, boolean canonicalize) throws IOExcept

throw new IOException("Cannot construct URI for " + remotePath);
}

public static URI canonicalize(URI uri) throws IOException {
if (uri.getScheme().equals("ssh")) {
return sshCanonicalize(uri);
}
return uri;
}
}

2 comments on commit b56141b

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b56141b Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b56141b Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.