mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49:01 +02:00
Replace use of assert with exceptions
asserts don't really belong in non-test code, let's handle these situations properly instead. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
9c65bf254e
commit
f6f747fb92
|
@ -369,7 +369,9 @@ def main():
|
||||||
urldir = layer.get_fetch_dir()
|
urldir = layer.get_fetch_dir()
|
||||||
repodir = os.path.join(fetchdir, urldir)
|
repodir = os.path.join(fetchdir, urldir)
|
||||||
repo = git.Repo(repodir)
|
repo = git.Repo(repodir)
|
||||||
assert repo.bare == False
|
if repo.bare:
|
||||||
|
logger.error('Repository %s is bare, not supported' % repodir)
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
# Always get origin/branchname, so it raises error when branch doesn't exist when nocheckout
|
# Always get origin/branchname, so it raises error when branch doesn't exist when nocheckout
|
||||||
topcommit = repo.commit('origin/%s' % branchname)
|
topcommit = repo.commit('origin/%s' % branchname)
|
||||||
|
|
|
@ -371,7 +371,9 @@ def main():
|
||||||
|
|
||||||
# Collect repo info
|
# Collect repo info
|
||||||
repo = git.Repo(repodir)
|
repo = git.Repo(repodir)
|
||||||
assert repo.bare == False
|
if repo.bare:
|
||||||
|
logger.error('Repository %s is bare, not supported' % repodir)
|
||||||
|
sys.exit(1)
|
||||||
topcommit = repo.commit('origin/%s' % branchname)
|
topcommit = repo.commit('origin/%s' % branchname)
|
||||||
if options.nocheckout:
|
if options.nocheckout:
|
||||||
topcommit = repo.commit('HEAD')
|
topcommit = repo.commit('HEAD')
|
||||||
|
|
|
@ -259,7 +259,8 @@ def is_branch_valid(layerdir, branch):
|
||||||
import git
|
import git
|
||||||
|
|
||||||
g = git.cmd.Git(layerdir)
|
g = git.cmd.Git(layerdir)
|
||||||
assert g.rev_parse('--is-bare-repository') == 'false'
|
if g.rev_parse('--is-bare-repository') != 'false':
|
||||||
|
raise Exception('is_branch_valid: git repository is a bare repository')
|
||||||
try:
|
try:
|
||||||
g.rev_parse('--verify', 'origin/%s' % branch)
|
g.rev_parse('--verify', 'origin/%s' % branch)
|
||||||
except git.exc.GitCommandError:
|
except git.exc.GitCommandError:
|
||||||
|
|
|
@ -139,7 +139,9 @@ def upgrade_history(options, logger):
|
||||||
since_option = '--since="%s" origin/master' % since
|
since_option = '--since="%s" origin/master' % since
|
||||||
|
|
||||||
repo = git.Repo(repodir)
|
repo = git.Repo(repodir)
|
||||||
assert repo.bare == False
|
if repo.bare:
|
||||||
|
logger.error('Repository %s is bare, not supported' % repodir)
|
||||||
|
continue
|
||||||
|
|
||||||
commits = utils.runcmd("git log %s --format='%%H %%ct' --reverse" % since_option,
|
commits = utils.runcmd("git log %s --format='%%H %%ct' --reverse" % since_option,
|
||||||
repodir,
|
repodir,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user