mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
deprecate GitPython
GitPython is not compatible with python3 and may never be: https://fedoraproject.org/wiki/User:Churchyard/python3
This commit is contained in:
parent
a0d0f859c7
commit
3ae1596923
4 changed files with 28 additions and 33 deletions
|
@ -12,7 +12,6 @@
|
|||
# granted to use or replicate Red Hat trademarks that are incorporated
|
||||
# in this software or its documentation.
|
||||
|
||||
import git
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
@ -117,23 +116,15 @@ class TitoGitTestFixture(unittest.TestCase):
|
|||
print("Testing in: %s" % self.repo_dir)
|
||||
print
|
||||
|
||||
# GitPython calls os.login(), which throws OSError if there is no tty,
|
||||
# but GitPython allows to avoid the call if env var USER exists.
|
||||
try:
|
||||
os.getlogin()
|
||||
except OSError:
|
||||
os.environ['USER'] = 'nobody'
|
||||
|
||||
# Initialize the repo:
|
||||
self.repo = git.Repo.init(path=self.repo_dir, mkdir=True, bare=False)
|
||||
os.chdir(self.repo_dir)
|
||||
run_command('git init')
|
||||
|
||||
# Next we tito init:
|
||||
os.chdir(self.repo_dir)
|
||||
tito("init")
|
||||
run_command('echo "offline = true" >> rel-eng/tito.props')
|
||||
index = self.repo.index
|
||||
index.add(['rel-eng/tito.props'])
|
||||
index.commit('Setting offline.')
|
||||
run_command('git add rel-eng/tito.props')
|
||||
run_command("git commit -m 'set offline in tito.props'")
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.repo_dir)
|
||||
|
@ -196,13 +187,12 @@ class TitoGitTestFixture(unittest.TestCase):
|
|||
out_f.write(TEST_PYTHON_SRC)
|
||||
out_f.close()
|
||||
|
||||
index = self.repo.index
|
||||
files = [os.path.join(pkg_dir, 'a.txt'),
|
||||
os.path.join(pkg_dir, 'setup.py'),
|
||||
os.path.join(pkg_dir, '%s.spec' % pkg_name),
|
||||
os.path.join(pkg_dir, 'src/module.py')
|
||||
]
|
||||
index.add(files)
|
||||
index.commit('Initial commit.')
|
||||
run_command('git add %s' % ' '.join(files))
|
||||
run_command("git commit -m 'initial commit'")
|
||||
|
||||
tito('tag --keep-version --debug --accept-auto-changelog')
|
||||
|
|
|
@ -68,20 +68,19 @@ class MultiProjectTests(TitoGitTestFixture):
|
|||
self.create_project(TEST_PKG_1, os.path.join(self.repo_dir, 'pkg1'))
|
||||
self.create_project(TEST_PKG_2, os.path.join(self.repo_dir, 'pkg2'))
|
||||
self.create_project(TEST_PKG_3, os.path.join(self.repo_dir, 'pkg3'))
|
||||
os.chdir(self.repo_dir)
|
||||
|
||||
# For second test package, use a tito.props to override and use the
|
||||
# ReleaseTagger:
|
||||
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
|
||||
filename = os.path.join(self.repo_dir, 'pkg2', "tito.props")
|
||||
out_f = open(filename, 'w')
|
||||
out_f.write("[buildconfig]\n")
|
||||
out_f.write("tagger = tito.tagger.ReleaseTagger\n")
|
||||
out_f.write("builder = tito.builder.Builder\n")
|
||||
out_f.close()
|
||||
index = self.repo.index
|
||||
index.add(['pkg2/tito.props'])
|
||||
index.commit("Adding tito.props for pkg2.")
|
||||
|
||||
os.chdir(self.repo_dir)
|
||||
run_command('git add pkg2/tito.props')
|
||||
run_command("git commit -m 'add tito.props for pkg2'")
|
||||
|
||||
def test_template_version_tagger(self):
|
||||
"""
|
||||
|
@ -94,9 +93,10 @@ class MultiProjectTests(TitoGitTestFixture):
|
|||
run_command('mkdir -p %s' % join(self.repo_dir, 'rel-eng/templates'))
|
||||
self.write_file(join(self.repo_dir,
|
||||
'rel-eng/templates/version.rb'), VERSION_TEMPLATE_FILE)
|
||||
index = self.repo.index
|
||||
index.add(['pkg3/tito.props'])
|
||||
index.commit("Adding tito.props for pkg3.")
|
||||
|
||||
os.chdir(self.repo_dir)
|
||||
run_command('git add pkg3/tito.props')
|
||||
run_command("git commit -m 'add tito.props for pkg3'")
|
||||
|
||||
# Create another pkg3 tag and make sure we got a generated
|
||||
# template file.
|
||||
|
|
|
@ -49,14 +49,21 @@ class SingleProjectTests(TitoGitTestFixture):
|
|||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||
|
||||
def test_undo_tag(self):
|
||||
commit = self.repo.heads.master.commit
|
||||
os.chdir(self.repo_dir)
|
||||
original_head = getoutput('git show-ref -s refs/heads/master')
|
||||
|
||||
# Create tito tag, which adds a new commit and moves head.
|
||||
tito("tag --accept-auto-changelog --debug")
|
||||
tag = "%s-0.0.2-1" % PKG_NAME
|
||||
check_tag_exists(tag, offline=True)
|
||||
self.assertNotEqual(commit, self.repo.heads.master.commit)
|
||||
new_head = getoutput('git show-ref -s refs/heads/master')
|
||||
self.assertNotEqual(original_head, new_head)
|
||||
|
||||
# Undo tito tag, which rewinds one commit to original head.
|
||||
tito("tag -u")
|
||||
self.assertFalse(tag_exists_locally(tag))
|
||||
self.assertEqual(commit, self.repo.heads.master.commit)
|
||||
new_head = getoutput('git show-ref -s refs/heads/master')
|
||||
self.assertEqual(original_head, new_head)
|
||||
|
||||
def test_latest_tgz(self):
|
||||
tito("build --tgz -o %s" % self.repo_dir)
|
||||
|
|
|
@ -25,9 +25,7 @@ class TitoUnitTestFixture(unittest.TestCase):
|
|||
Fixture providing setup/teardown and utilities for unit tests.
|
||||
"""
|
||||
def setUp(self):
|
||||
# GitPython calls os.login(), which throws OSError if there is no tty,
|
||||
# but GitPython allows to avoid the call if env var USER exists.
|
||||
try:
|
||||
os.getlogin()
|
||||
except OSError:
|
||||
os.environ['USER'] = 'nobody'
|
||||
print
|
||||
print
|
||||
print("Testing in: %s" % REPO_DIR)
|
||||
print
|
||||
|
|
Loading…
Add table
Reference in a new issue