예제 #1
0
 def test_make_commit_should_set_last_commit(self):
     branch = Branch('master')
     branch.init_config()
     self.assertEquals(self.index.last_commit, 'None')
     self.index.add_new_file('TESTING.txt')
     self.index.make_commit("new commit", 'master')
     self.assertIsNotNone(self.index.last_commit)
예제 #2
0
 def init(self):
     """Initializes repository with master branch"""
     branch = Branch('master')
     branch.init_config()
     self.__current_branch_name = 'master'
     self.head.init_config()
     self.head.current_branch = branch
     self.init_config()
예제 #3
0
 def test_reset_should_reset_to_head_commit(self):
     head = Head()
     head.init_config()
     branch = Branch('master')
     branch.init_config()
     head.current_branch = branch
     commit = Commit('test')
     commit.branch_name = 'master'
     commit.init_config()
     head.current_branch.set_current_commit(commit)
     self.index.reset(head)
     self.assertEqual(self.index.last_commit.commit_number,
                      commit.commit_number)
예제 #4
0
 def test_reset_should_move_head_to_previous_commit(self):
     di = DirectoryInfo()
     di.init(os.getcwd())
     head = Head()
     head.init_config()
     branch = Branch('master')
     branch.init_config()
     head.current_branch = branch
     commit = Commit('first')
     commit.branch_name = 'master'
     commit.init_config()
     prev_commit = Commit('second')
     prev_commit.branch_name = 'master'
     prev_commit.init_config()
     commit.set_previous_commit_number(prev_commit.commit_number)
     previous_commit_number = commit.get_previous_commit_number()
     head.current_branch.set_current_commit(commit)
     head.reset()
     current_commit = head.current_branch.get_current_commit()
     self.assertEqual(current_commit.commit_number, previous_commit_number)
예제 #5
0
 def test_make_commit_should_return_new_commit(self):
     branch = Branch('master')
     branch.init_config()
     self.index.add_new_file('TESTING.txt')
     commit = self.index.make_commit("new commit", 'master')
     self.assertIsNotNone(commit)