Skip to content

Commit 620b93a

Browse files
committed
[link-me] Support SSH remote URLs as well
1 parent 2df77dc commit 620b93a

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: remote
8+
remote-url: git@github.com/git-mastery/link-me.git
9+
remote-name: upstream

link_me/tests/specs/valid.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ initialization:
55
message: Empty commit
66
id: start
77
- type: remote
8-
remote-url: https://github.com/git-mastery/link-me
8+
remote-url: https://github.com/git-mastery/link-me.git
99
remote-name: upstream

link_me/tests/specs/valid_ssh.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: remote
8+
remote-url: git@github.com:git-mastery/link-me.git
9+
remote-name: upstream

link_me/tests/test_verify.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ def test_valid():
1212
assert_output(output, GitAutograderStatus.SUCCESSFUL)
1313

1414

15+
def test_valid_ssh():
16+
with loader.load("specs/valid_ssh.yml", "start") as output:
17+
assert_output(output, GitAutograderStatus.SUCCESSFUL)
18+
19+
20+
def test_invalid_ssh():
21+
with loader.load("specs/invalid_ssh.yml", "start") as output:
22+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [WRONG_UPSTREAM_URL])
23+
24+
1525
def test_wrong_url():
1626
with loader.load("specs/wrong_url.yml", "start") as output:
1727
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [WRONG_UPSTREAM_URL])

link_me/verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
1313
raise exercise.wrong_answer([MISSING_UPSTREAM_REMOTE])
1414

1515
upstream = exercise.repo.remotes.remote("upstream")
16-
if not upstream.remote.url.startswith("https://github.com/git-mastery/link-me"):
16+
if not upstream.is_for_repo("git-mastery", "link-me"):
1717
raise exercise.wrong_answer([WRONG_UPSTREAM_URL])
1818

1919
return exercise.to_output(

0 commit comments

Comments
 (0)