Skip to content

Commit 20291f5

Browse files
author
Jessica Lord
authored
Merge pull request #146 from jlord/update-branches-text
Update Fork and Branches challenges
2 parents 50c5d2d + d9bf399 commit 20291f5

File tree

5 files changed

+65
-22
lines changed

5 files changed

+65
-22
lines changed

challenge-content/6_forks_and_clones.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ <h3>Connect to the Original Repository</h3>
4646

4747
<p><code class="shell">git remote add upstream https://github.com/jlord/patchwork.git</code></p>
4848

49-
<p>To be sure you have the correct remotes set up, type <code>git remote -v</code> to list out the addresses you have stored. You should have an 'origin' remote with <em>your fork's</em> address and then an 'upstream' remote with the address to the original, with the URL noted above in this step.</p>
49+
<p>To be sure you have the correct remotes set up, type <code>git remote -v</code> to list out the addresses you have stored. <b>You should have an 'origin' remote with your fork's address and then an 'upstream' remote with the address to the original, the URL noted above in this step.</b></p>
5050
</div>
5151

5252
{{{ verify_directory_button }}}
5353

5454
<div class="chal-tip grey-border border-box">
5555
<ul class="no-list-style">
56-
<li><strong>Add remote connections</strong></li>
56+
<li><strong>Add a remote</strong></li>
5757
<li><code class="shell">git remote add &#60;REMOTENAME&#62; &#60;URL&#62;</code></li>
58+
<li><strong>Change a remote URL</strong></li>
59+
<li><code class="shell">git remote set-url &#60;REMOTENAME&#62; &#60;URL&#62;</code></li>
5860
<li><strong>View remote connections</strong></li>
5961
<li><code class="shell">git remote -v</code></li>
6062
</ul>

challenge-content/7_branches_arent_just_for_birds.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ <h3>Check-in</h3>
5454
<p><code class="shell">git add &#60;FILENAME&#62;</code></p>
5555
<p><code class="shell">git commit -m "commit message"</code></p>
5656

57-
<p>Now push your update to your fork on GitHub:</p>
57+
<p>Now push your update to <b>your fork</b>, 'origin', on GitHub:</p>
5858
<p><code class="shell">git push origin &#60;BRANCHNAME&#62;</code></p>
59-
60-
<p>Make sure that you're pushing to 'origin', which is your fork's address on GitHub. If you get an error check to make sure you have your remotes set up correctly with 'origin' pointing to your fork and 'upstream' pointing to the original repository: <code>git remote -v</code>
6159
</div>
6260

6361
{{{ verify_directory_button }}}
6462

6563
<div class="chal-no-pass grey-border border-box">
64+
<h4>Permission denied...error: 403</h4>
65+
<p>You are pushing changes to a repository you don't have write access to. In this case, you're likely pushing ot the original 'jlord/patchwork'. Make sure that you're pushing to 'origin' and that it points to your fork's address on GitHub. To check and see what your remotes are and where they point run <code>git remote -v</code>. You should have 'upstream' pointing to 'jlord/patchwork' and 'origin' pointing to 'yourusername/patchwork'.
66+
67+
<p>To fix a remote that is pointing to the wrong place you can re-set its url: <code>git remote set-url origin <URLTOYOURFORK></code>.
68+
6669
<h4>File NOT in contributors folder</h4>
6770
<p>The file you create should be placed inside the existing 'contributors' folder in the Patchwork repository. If you put it somewhere else, simply use Finder or Windows Explorer to move your file into the folder. You can check <code>git status</code> again and you'll find it sees your changes. Stage and then commit "all" (-A) of these changes (additions and deletions) with the commands below.</p>
6871
<p><code class="shell">git add -A</code></p>

challenges/branches_arent_just_for_birds.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,8 @@ <h3>Check-in</h3>
168168
<p><code class="shell">git add &#60;FILENAME&#62;</code></p>
169169
<p><code class="shell">git commit -m "commit message"</code></p>
170170

171-
<p>Now push your update to your fork on GitHub:</p>
171+
<p>Now push your update to <b>your fork</b>, 'origin', on GitHub:</p>
172172
<p><code class="shell">git push origin &#60;BRANCHNAME&#62;</code></p>
173-
174-
<p>Make sure that you're pushing to 'origin', which is your fork's address on GitHub. If you get an error check to make sure you have your remotes set up correctly with 'origin' pointing to your fork and 'upstream' pointing to the original repository: <code>git remote -v</code>
175173
</div>
176174

177175
<div class="verify bold-blue solid-box">
@@ -189,6 +187,11 @@ <h3>Check-in</h3>
189187
</div>
190188

191189
<div class="chal-no-pass grey-border border-box">
190+
<h4>Permission denied...error: 403</h4>
191+
<p>You are pushing changes to a repository you don't have write access to. In this case, you're likely pushing ot the original 'jlord/patchwork'. Make sure that you're pushing to 'origin' and that it points to your fork's address on GitHub. To check and see what your remotes are and where they point run <code>git remote -v</code>. You should have 'upstream' pointing to 'jlord/patchwork' and 'origin' pointing to 'yourusername/patchwork'.
192+
193+
<p>To fix a remote that is pointing to the wrong place you can re-set its url: <code>git remote set-url origin <URLTOYOURFORK></code>.
194+
192195
<h4>File NOT in contributors folder</h4>
193196
<p>The file you create should be placed inside the existing 'contributors' folder in the Patchwork repository. If you put it somewhere else, simply use Finder or Windows Explorer to move your file into the folder. You can check <code>git status</code> again and you'll find it sees your changes. Stage and then commit "all" (-A) of these changes (additions and deletions) with the commands below.</p>
194197
<p><code class="shell">git add -A</code></p>

challenges/forks_and_clones.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ <h3>Connect to the Original Repository</h3>
160160

161161
<p><code class="shell">git remote add upstream https://github.com/jlord/patchwork.git</code></p>
162162

163-
<p>To be sure you have the correct remotes set up, type <code>git remote -v</code> to list out the addresses you have stored. You should have an 'origin' remote with <em>your fork's</em> address and then an 'upstream' remote with the address to the original, with the URL noted above in this step.</p>
163+
<p>To be sure you have the correct remotes set up, type <code>git remote -v</code> to list out the addresses you have stored. <b>You should have an 'origin' remote with your fork's address and then an 'upstream' remote with the address to the original, the URL noted above in this step.</b></p>
164164
</div>
165165

166166
<div class="verify bold-blue solid-box">
@@ -179,8 +179,10 @@ <h3>Connect to the Original Repository</h3>
179179

180180
<div class="chal-tip grey-border border-box">
181181
<ul class="no-list-style">
182-
<li><strong>Add remote connections</strong></li>
182+
<li><strong>Add a remote</strong></li>
183183
<li><code class="shell">git remote add &#60;REMOTENAME&#62; &#60;URL&#62;</code></li>
184+
<li><strong>Change a remote URL</strong></li>
185+
<li><code class="shell">git remote set-url &#60;REMOTENAME&#62; &#60;URL&#62;</code></li>
184186
<li><strong>View remote connections</strong></li>
185187
<li><code class="shell">git remote -v</code></li>
186188
</ul>

lib/verify/forks_and_clones.js

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ var helper = require('../helpers.js')
77
var userData = require('../user-data.js')
88

99
var addToList = helper.addToList
10-
var markChallengeCompleted = helper.markChallengeCompleted
1110

1211
var currentChallenge = 'forks_and_clones'
12+
var username = ''
1313

1414
// check that they've added the remote, that shows
1515
// that they've also then forked and cloned.
@@ -19,20 +19,53 @@ module.exports = function verifyForksAndClonesChallenge (path) {
1919
addToList('Path is not a directory', false)
2020
return helper.challengeIncomplete()
2121
}
22-
exec('remote -v', {cwd: path}, function (err, stdout, stdrr) {
22+
23+
exec('config user.username', function (err, stdout, stderr) {
2324
if (err) {
2425
addToList('Error: ' + err.message, false)
2526
return helper.challengeIncomplete()
2627
}
27-
var show = stdout.trim()
28-
29-
if (show.match('upstream') && show.match('github.com[\:\/]jlord/')) {
30-
addToList('Upstream remote set up!', true)
31-
markChallengeCompleted(currentChallenge)
32-
userData.updateData(currentChallenge)
33-
} else {
34-
addToList('No upstream remote matching /jlord/Patchwork.', false)
35-
helper.challengeIncomplete()
36-
}
28+
username = stdout.trim()
29+
30+
exec('remote -v', {cwd: path}, function (err, stdout, stdrr) {
31+
if (err) {
32+
addToList('Error: ' + err.message, false)
33+
return helper.challengeIncomplete()
34+
}
35+
var remotes = stdout.trim().split('\n')
36+
if (remotes.length != 4) {
37+
addToList('Not finding 2 remotes set up.', false)
38+
helper.challengeIncomplete()
39+
userData.updateData(currentChallenge)
40+
return
41+
}
42+
// TODO this is getting wild
43+
remotes.splice(1, 2)
44+
var incomplete = 0
45+
46+
remotes.forEach(function (remote) {
47+
if (remote.match('origin')) {
48+
if (remote.match('github.com[\:\/]' + username + '/')) {
49+
addToList('Origin points to your fork!', true)
50+
} else {
51+
incomplete++
52+
addToList('Origin remote not pointing to ' + username + '/patchwork', false)
53+
54+
}
55+
}
56+
if (remote.match('upstream')) {
57+
if (remote.match('github.com[\:\/]jlord/')) {
58+
addToList('Upstream remote set up!', true)
59+
} else {
60+
incomplete++
61+
addToList('Upstream remote not pointing to jlord/patchwork', false)
62+
}
63+
}
64+
})
65+
if (incomplete === 0) {
66+
userData.updateData(currentChallenge)
67+
helper.markChallengeCompleted(currentChallenge)
68+
} else helper.challengeIncomplete()
69+
})
3770
})
3871
}

0 commit comments

Comments
 (0)