def restore_temp_commit(flags, restore_data): """ Restores the initial state before a temp commit was created. - restore_data -- The restore data returned from the 'create_temp_commit' function. """ try: # Restore branch. if restore_data[0] != get_branch(): log(flags, "Switching active branch to \'" + restore_data[0] + "\'") switch_branch(restore_data[0]) # Check if changes have been stashed (and temporary commit created). if restore_data[2] is not None: log(flags, "Resetting branch \'" + restore_data[0] + "\'to commit \'" + restore_data[1] + "\'") reset_branch(flags, restore_data[0], restore_data[1]) log(flags, "Restoring uncommitted changes from stash to " + "branch \'" + restore_data[0] + "\'") apply_stash(flags, restore_data[0], drop=True) except Error as err: raise OpError(err)
def set_up(): # Init repository with one file. remove_dir(_FLAGS, _TEST_DIR) mkdirs(_FLAGS, _TEST_DIR) init_repository(_FLAGS, _TEST_DIR) chdir(_TEST_DIR) create_file(_FLAGS, _TEST_FILE) commit_changes(_FLAGS, "Test file added.") # Create branches. create_branch(_FLAGS, _UPSTREAM) switch_branch(_UPSTREAM) create_branch(_FLAGS, _DEBIAN) switch_branch(_DEBIAN) mkdirs(_FLAGS, path.dirname(_TEST_DEBIAN_FILE)) create_file(_FLAGS, _TEST_DEBIAN_FILE) commit_changes(_FLAGS, "Test debian file added.") # Commit ignored file and config. switch_branch(_RELEASE) create_file(_FLAGS, _IGNORE_FILE) create_file(_FLAGS, _TEST_FILE2) execute_with(action=Action.CONFIG) commit_changes(_FLAGS, "Ignored file added.")
def test_debian_integrity(self): switch_branch(_DEBIAN) self.assertTrue(path.exists(_TEST_FILE)) self.assertTrue(path.exists(_TEST_FILE2)) self.assertFalse(path.exists(_IGNORE_FILE)) self.assertTrue(len(listdir(".")) == 3)
def test_upstream_integrity(self): switch_branch(_UPSTREAM) self.assertTrue(path.exists(_TEST_FILE)) self.assertTrue(path.exists(_TEST_FILE2)) self.assertFalse(path.exists(_IGNORE_FILE)) self.assertTrue(len(listdir(".")) == 3)