From 2fee56c915ef020e0936dc49a56d4ea778ba8d93 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 7 Jul 2016 21:05:04 -0700 Subject: [PATCH 1/3] Explicitly check origin remote --- lib/verify/forks_and_clones.js | 57 +++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/lib/verify/forks_and_clones.js b/lib/verify/forks_and_clones.js index 9e78d499ce..88cf542f16 100644 --- a/lib/verify/forks_and_clones.js +++ b/lib/verify/forks_and_clones.js @@ -7,9 +7,9 @@ var helper = require('../helpers.js') var userData = require('../user-data.js') var addToList = helper.addToList -var markChallengeCompleted = helper.markChallengeCompleted var currentChallenge = 'forks_and_clones' +var username = '' // check that they've added the remote, that shows // that they've also then forked and cloned. @@ -19,20 +19,53 @@ module.exports = function verifyForksAndClonesChallenge (path) { addToList('Path is not a directory', false) return helper.challengeIncomplete() } - exec('remote -v', {cwd: path}, function (err, stdout, stdrr) { + + exec('config user.username', function (err, stdout, stderr) { if (err) { addToList('Error: ' + err.message, false) return helper.challengeIncomplete() } - var show = stdout.trim() - - if (show.match('upstream') && show.match('github.com[\:\/]jlord/')) { - addToList('Upstream remote set up!', true) - markChallengeCompleted(currentChallenge) - userData.updateData(currentChallenge) - } else { - addToList('No upstream remote matching /jlord/Patchwork.', false) - helper.challengeIncomplete() - } + username = stdout.trim() + + exec('remote -v', {cwd: path}, function (err, stdout, stdrr) { + if (err) { + addToList('Error: ' + err.message, false) + return helper.challengeIncomplete() + } + var remotes = stdout.trim().split('\n') + if (remotes.length != 4) { + addToList('Not finding 2 remotes set up.', false) + helper.challengeIncomplete() + userData.updateData(currentChallenge) + return + } + // TODO this is getting wild + remotes.splice(1, 2) + var incomplete = 0 + + remotes.forEach(function (remote) { + if (remote.match('origin')) { + if (remote.match('github.com[\:\/]' + username + '/')) { + addToList('Origin points to your fork!', true) + } else { + incomplete++ + addToList('Origin remote not pointing to ' + username + '/patchwork', false) + + } + } + if (remote.match('upstream')) { + if (remote.match('github.com[\:\/]jlord/')) { + addToList('Upstream remote set up!', true) + } else { + incomplete++ + addToList('Upstream remote not pointing to jlord/patchwork', false) + } + } + }) + if (incomplete === 0) { + userData.updateData(currentChallenge) + helper.markChallengeCompleted(currentChallenge) + } else helper.challengeIncomplete() + }) }) } From 1d815ce9f541fcfeaa74956e2018bac4271244b2 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 7 Jul 2016 21:05:20 -0700 Subject: [PATCH 2/3] Update challenge text --- challenge-content/7_branches_arent_just_for_birds.html | 9 ++++++--- challenges/branches_arent_just_for_birds.html | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/challenge-content/7_branches_arent_just_for_birds.html b/challenge-content/7_branches_arent_just_for_birds.html index 9b0d96d055..4273d90fa1 100644 --- a/challenge-content/7_branches_arent_just_for_birds.html +++ b/challenge-content/7_branches_arent_just_for_birds.html @@ -54,15 +54,18 @@

Check-in

git add <FILENAME>

git commit -m "commit message"

-

Now push your update to your fork on GitHub:

+

Now push your update to your fork, 'origin', on GitHub:

git push origin <BRANCHNAME>

- -

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: git remote -v {{{ verify_directory_button }}}

+

Permission denied...error: 403

+

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 git remote -v. You should have 'upstream' pointing to 'jlord/patchwork' and 'origin' pointing to 'yourusername/patchwork'. + +

To fix a remote that is pointing to the wrong place you can re-set its url: git remote set-url origin . +

File NOT in contributors folder

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 git status 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.

git add -A

diff --git a/challenges/branches_arent_just_for_birds.html b/challenges/branches_arent_just_for_birds.html index 7c38698b0c..183cdd1ce7 100644 --- a/challenges/branches_arent_just_for_birds.html +++ b/challenges/branches_arent_just_for_birds.html @@ -168,10 +168,8 @@

Check-in

git add <FILENAME>

git commit -m "commit message"

-

Now push your update to your fork on GitHub:

+

Now push your update to your fork, 'origin', on GitHub:

git push origin <BRANCHNAME>

- -

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: git remote -v

@@ -189,6 +187,11 @@

Check-in

+

Permission denied...error: 403

+

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 git remote -v. You should have 'upstream' pointing to 'jlord/patchwork' and 'origin' pointing to 'yourusername/patchwork'. + +

To fix a remote that is pointing to the wrong place you can re-set its url: git remote set-url origin . +

File NOT in contributors folder

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 git status 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.

git add -A

From d9bf399e857f86349b8885ada3ff16c83484b51e Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 7 Jul 2016 21:05:28 -0700 Subject: [PATCH 3/3] Update challenge text --- challenge-content/6_forks_and_clones.html | 6 ++++-- challenges/forks_and_clones.html | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/challenge-content/6_forks_and_clones.html b/challenge-content/6_forks_and_clones.html index 592323b27e..e1ebac0e15 100644 --- a/challenge-content/6_forks_and_clones.html +++ b/challenge-content/6_forks_and_clones.html @@ -46,15 +46,17 @@

Connect to the Original Repository

git remote add upstream https://github.com/jlord/patchwork.git

-

To be sure you have the correct remotes set up, type git remote -v to list out the addresses you have stored. You should have an 'origin' remote with your fork's address and then an 'upstream' remote with the address to the original, with the URL noted above in this step.

+

To be sure you have the correct remotes set up, type git remote -v to list out the addresses you have stored. 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.

{{{ verify_directory_button }}}
    -
  • Add remote connections
  • +
  • Add a remote
  • git remote add <REMOTENAME> <URL>
  • +
  • Change a remote URL
  • +
  • git remote set-url <REMOTENAME> <URL>
  • View remote connections
  • git remote -v
diff --git a/challenges/forks_and_clones.html b/challenges/forks_and_clones.html index 52413ef9e9..10728741f4 100644 --- a/challenges/forks_and_clones.html +++ b/challenges/forks_and_clones.html @@ -160,7 +160,7 @@

Connect to the Original Repository

git remote add upstream https://github.com/jlord/patchwork.git

-

To be sure you have the correct remotes set up, type git remote -v to list out the addresses you have stored. You should have an 'origin' remote with your fork's address and then an 'upstream' remote with the address to the original, with the URL noted above in this step.

+

To be sure you have the correct remotes set up, type git remote -v to list out the addresses you have stored. 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.

@@ -179,8 +179,10 @@

Connect to the Original Repository

    -
  • Add remote connections
  • +
  • Add a remote
  • git remote add <REMOTENAME> <URL>
  • +
  • Change a remote URL
  • +
  • git remote set-url <REMOTENAME> <URL>
  • View remote connections
  • git remote -v