levels/fetch.rb in githug-0.5.0 vs levels/fetch.rb in githug-0.5.1

- old
+ new

@@ -7,26 +7,27 @@ # initialize another git repo to be used as a "remote" tmpdir = Dir.mktmpdir # local repo repo.init + system "git branch -m master" - #adds a file to origin/master + # adds a file to origin/master FileUtils.touch "master_file" repo.add "master_file" repo.commit_all 'Commits master_file' # remote repo Dir.chdir tmpdir repo.init - #adds a file to origin/master + # adds a file to origin/master FileUtils.touch "master_file" repo.add "master_file" repo.commit_all 'Commits master_file' - - #adds remote repo + + # adds remote repo Dir.chdir cwd `git remote add origin #{tmpdir}/.git` `git fetch origin --quiet` `git branch -u origin/master master 2> /dev/null` @@ -36,34 +37,33 @@ # adds a file into the new branch. Should not be pulled into the local FileUtils.touch "file1" repo.add "file1" repo.commit_all 'Commits file 1' - + end solution do repo.init result = true - # counts the number of local branches. Should equal 1 local_branches = repo.branches.size # after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line - # This command will count the number of lines, which will give the number of branches - if File.file?('.git/FETCH_HEAD') #checks for file existance - num_remote = File.read(".git/FETCH_HEAD").split("\n").count + # This command will count the number of lines, which will give the number of branches + if File.file?('.git/FETCH_HEAD') # checks for file existence + num_remote = File.read(".git/FETCH_HEAD").split("\n").count else - num_remote = 0 + num_remote = 0 end # there should be 1 local branch and 2 remote branches for a success condition if local_branches == 1 and num_remote == 2 - result = true + result = true else - result = false - end + result = false + end end hint do puts "Look up the 'git fetch' command" end