Skip to content

Commit

Permalink
Merge branch 'master' into verify-case-early
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessica Lord committed Sep 16, 2014
2 parents e1b082a + d6bae91 commit 7959abb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions problems/branches_arent_just_for_birds/solution.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
console.log("Found the branch as expected!")
console.log("Changes have been pushed!")
console.log("Found branch as expected!")
console.log("Changes have been pushed!")
36 changes: 20 additions & 16 deletions problems/branches_arent_just_for_birds/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
var exec = require('child_process').exec

// get their username
// verify branch matches username
// verify branch matches username, case too.
// verify they've pushed

exec('git config user.username', function(err, stdout, stdrr) {
var username = stdout.trim().toLowerCase()

exec('git status', function(err, stdout, stderr) {
var branch = stdout.trim().toLowerCase()
var branchName = "add-" + username
exec('git reflog show origin/' + branchName, function(err, stdout, stderr) {

var ref = stdout.trim()
if (branch.match(branchName)) console.log("Found the branch as expected!")
else console.log("branch name was not:\n'" + branchName + "'")

if (ref.match("update by push")) console.log("Changes have been pushed!")
else console.log("Changes not pushed")

})
var username = stdout.trim()

exec('git rev-parse --abbrev-ref HEAD', function(err, stdout, stderr) {
var actualBranch = stdout.trim()
var expectedBranch = "add-" + username
if (actualBranch.match(expectedBranch)) {
return console.log("Found branch as expected!")
checkPush(actualBranch)
} else {
console.log("Branch name expected: " + expectedBranch)
checkPush(actualBranch)
}
})
})

function checkPush(branchname) {
exec('git reflog show origin/' + branchname, function(err, stdout, stderr) {
if (stdout.match("update by push")) console.log("Changes have been pushed!")
else console.log("Changes not pushed")
})
}

0 comments on commit 7959abb

Please sign in to comment.