def test_describe_never_tagged_before(self): git = Git(root_dir_local, test_repo_dir) git.clone() lib.call_and_exit_if_failed( 'git tag -a release/0.1.1 -m \'releasing version\'') latest_tag = git.describe() self.assertEqual(latest_tag, "0.1.1")
def tag(self, commit_id, tag): path = self.path() os.chdir(path) lib.call_and_exit_if_failed('git tag -a ' + tag + ' -m \'releasing version ' + tag + ' of ' + self.repo_name() + '\' ' + commit_id) print 'Pushing new tag ' + tag + ' to origin' lib.call_and_exit_if_failed('git push -q origin ' + tag)
def clone(self): path = self.path() if not os.path.exists(path): if not os.path.exists(self.root_dir): os.mkdir(self.root_dir) os.chdir(self.root_dir) if self.verbose: print 'cloning into ' + path lib.call_and_exit_if_failed('git clone -q %s' % self.repo_url) os.chdir(path) lib.call_and_exit_if_failed('git fetch -q')
def test_update(self): git = Git(root_dir_local, test_repo_dir) git.clone() self.assertTrue(os.path.exists(os.path.join(test_repo_dir, "ANOTHER_FILE.txt")) != 1) os.chdir(test_repo_dir) with open("ANOTHER_FILE.txt", "a") as the_file: the_file.write("Another file") lib.call_and_exit_if_failed("git add .") lib.call_and_exit_if_failed('git commit -m "another commit"') git.update() self.assertTrue(os.path.exists(os.path.join(test_repo_dir, "ANOTHER_FILE.txt")) == 1)
def test_update(self): git = Git(root_dir_local, test_repo_dir) git.clone() self.assertTrue( os.path.exists(os.path.join(test_repo_dir, "ANOTHER_FILE.txt")) != 1) os.chdir(test_repo_dir) with open('ANOTHER_FILE.txt', 'a') as the_file: the_file.write('Another file') lib.call_and_exit_if_failed('git add .') lib.call_and_exit_if_failed('git commit -m "another commit"') git.update() self.assertTrue( os.path.exists(os.path.join(test_repo_dir, "ANOTHER_FILE.txt")) == 1)
def setUp(self): # This is setting up a local git server with a test project if not os.path.exists(root_dir_remote): os.makedirs(test_repo_dir) os.chdir(test_repo_dir) lib.call_and_exit_if_failed("git init") with open("README.md", "a") as the_file: the_file.write("Hello") lib.call_and_exit_if_failed("git add .") lib.call_and_exit_if_failed('git commit -m "test"')
def setUp(self): # This is setting up a local git server with a test project if not os.path.exists(root_dir_remote): os.makedirs(test_repo_dir) os.chdir(test_repo_dir) lib.call_and_exit_if_failed('git init') with open('README.md', 'a') as the_file: the_file.write('Hello') lib.call_and_exit_if_failed('git add .') lib.call_and_exit_if_failed('git commit -m "test"')
def latest_commit_id(self): query = lib.call_and_exit_if_failed('git log -1 --pretty="%H"') return query.stdout.read().strip()
def update(self): path = self.path() os.chdir(path) lib.call_and_exit_if_failed('git checkout -q ' + branch) lib.call_and_exit_if_failed('git pull -q origin ' + branch)
def test_describe_never_tagged_before(self): git = Git(root_dir_local, test_repo_dir) git.clone() lib.call_and_exit_if_failed("git tag -a release/0.1.1 -m 'releasing version'") latest_tag = git.describe() self.assertEqual(latest_tag, "0.1.1")