本文整理汇总了Python中gbp.deb.git.DebianGitRepository.version_to_tag方法的典型用法代码示例。如果您正苦于以下问题:Python DebianGitRepository.version_to_tag方法的具体用法?Python DebianGitRepository.version_to_tag怎么用?Python DebianGitRepository.version_to_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbp.deb.git.DebianGitRepository
的用法示例。
在下文中一共展示了DebianGitRepository.version_to_tag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
ret = 1
repo = None
(options, args) = parse_args(argv)
if not options:
return ExitCodes.parse_error
if len(args) != 2 or args[0] not in ['commit']:
gbp.log.err("No action given")
return 1
else:
tarball = args[1]
try:
try:
repo = DebianGitRepository('.')
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
source = DebianSource('.')
component_tarballs = get_component_tarballs(source.sourcepkg,
source.upstream_version,
tarball,
options.components)
upstream_tag = repo.version_to_tag(options.upstream_tag,
source.upstream_version)
repo.create_pristine_tar_commits(upstream_tag,
tarball,
component_tarballs)
ret = 0
except (GitRepositoryError, GbpError, CommandExecFailed) as err:
if str(err):
gbp.log.err(err)
except KeyboardInterrupt:
gbp.log.err("Interrupted. Aborting.")
if not ret:
comp_msg = (' with additional tarballs for %s'
% ", ".join([os.path.basename(t[1]) for t in component_tarballs])) if component_tarballs else ''
gbp.log.info("Successfully committed pristine-tar data for version %s of %s%s" % (source.upstream_version,
tarball,
comp_msg))
return ret
示例2: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
#.........这里部分代码省略.........
if branch != options.debian_branch:
gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
raise GbpError("Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name.")
tree = write_tree(repo, options)
cp = fetch_changelog(repo, options, tree)
if not options.tag_only:
output_dir = prepare_output_dir(options.export_dir)
tarball_dir = options.tarball_dir or output_dir
# Get/build the upstream tarball if necessary. We delay this in
# case of a postexport hook so the hook gets a chance to modify the
# sources and create different tarballs (#640382)
# We don't delay it in general since we want to fail early if the
# tarball is missing.
if not cp.is_native():
if options.postexport:
gbp.log.info("Postexport hook set, delaying tarball creation")
else:
prepare_upstream_tarball(repo, cp, options, tarball_dir,
output_dir)
# Export to another build dir if requested:
if options.export_dir:
tmp_dir = os.path.join(output_dir, "%s-tmp" % cp['Source'])
export_source(repo, tree, cp, options, tmp_dir, output_dir)
# Run postexport hook
if options.postexport:
RunAtCommand(options.postexport, shell=True,
extra_env={'GBP_GIT_DIR': repo.git_dir,
'GBP_TMP_DIR': tmp_dir})(dir=tmp_dir)
major = (cp.debian_version if cp.is_native() else cp.upstream_version)
export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major))
gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
# Delayed tarball creation in case a postexport hook is used:
if not cp.is_native() and options.postexport:
prepare_upstream_tarball(repo, cp, options, tarball_dir,
output_dir)
if options.export_dir:
build_dir = export_dir
else:
build_dir = repo_dir
if options.prebuild:
RunAtCommand(options.prebuild, shell=True,
extra_env={'GBP_GIT_DIR': repo.git_dir,
'GBP_BUILD_DIR': build_dir})(dir=build_dir)
setup_pbuilder(options)
# Finally build the package:
RunAtCommand(options.builder, dpkg_args, shell=True,
extra_env={'GBP_BUILD_DIR': build_dir})(dir=build_dir)
if options.postbuild:
arch = os.getenv('ARCH', None) or du.get_arch()
changes = os.path.abspath("%s/../%s_%s_%s.changes" %
(build_dir, cp['Source'], cp.noepoch, arch))
gbp.log.debug("Looking for changes file %s" % changes)
if not os.path.exists(changes):
changes = os.path.abspath("%s/../%s_%s_source.changes" %
(build_dir, cp['Source'], cp.noepoch))
Command(options.postbuild, shell=True,
extra_env={'GBP_CHANGES_FILE': changes,
'GBP_BUILD_DIR': build_dir})()
if options.tag or options.tag_only:
gbp.log.info("Tagging %s" % cp.version)
tag = repo.version_to_tag(options.debian_tag, cp.version)
if options.retag and repo.has_tag(tag):
repo.delete_tag(tag)
repo.create_tag(name=tag, msg="Debian release %s" % cp.version,
sign=options.sign_tags, keyid=options.keyid)
if options.posttag:
sha = repo.rev_parse("%s^{}" % tag)
Command(options.posttag, shell=True,
extra_env={'GBP_TAG': tag,
'GBP_BRANCH': branch or '(no branch)',
'GBP_SHA1': sha})()
except CommandExecFailed:
retval = 1
except (GbpError, GitRepositoryError) as err:
if len(err.__str__()):
gbp.log.err(err)
retval = 1
finally:
drop_index()
if not options.tag_only:
if options.export_dir and options.purge and not retval:
RemoveTree(export_dir)()
if cp and not gbp.notifications.notify(cp, not retval, options.notify):
gbp.log.err("Failed to send notification")
retval = 1
return retval
示例3: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
ret = 0
tmpdir = ''
pristine_orig = None
linked = False
(options, args) = parse_args(argv)
if not options:
return 1
try:
source = find_source(options.uscan, args)
if not source:
return ret
try:
repo = DebianGitRepository('.')
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
# an empty repo has now branches:
initial_branch = repo.get_branch()
is_empty = False if initial_branch else True
if not repo.has_branch(options.upstream_branch) and not is_empty:
raise GbpError(no_upstream_branch_msg % options.upstream_branch)
(sourcepackage, version) = detect_name_and_version(repo, source, options)
(clean, out) = repo.is_clean()
if not clean and not is_empty:
gbp.log.err("Repository has uncommitted changes, commit these first: ")
raise GbpError(out)
if repo.bare:
set_bare_repo_options(options)
if not source.is_dir():
tmpdir = tempfile.mkdtemp(dir='../')
source.unpack(tmpdir, options.filters)
gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
if source.needs_repack(options):
gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
(source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters)
(pristine_orig, linked) = prepare_pristine_tar(source.path,
sourcepackage,
version)
# Don't mess up our repo with git metadata from an upstream tarball
try:
if os.path.isdir(os.path.join(source.unpacked, '.git/')):
raise GbpError("The orig tarball contains .git metadata - giving up.")
except OSError:
pass
try:
upstream_branch = [ options.upstream_branch, 'master' ][is_empty]
filter_msg = ["", " (filtering out %s)"
% options.filters][len(options.filters) > 0]
gbp.log.info("Importing '%s' to branch '%s'%s..." % (source.path,
upstream_branch,
filter_msg))
gbp.log.info("Source package is %s" % sourcepackage)
gbp.log.info("Upstream version is %s" % version)
import_branch = [ options.upstream_branch, None ][is_empty]
msg = upstream_import_commit_msg(options, version)
if options.vcs_tag:
parents = [repo.rev_parse("%s^{}" % options.vcs_tag)]
else:
parents = None
commit = repo.commit_dir(source.unpacked,
msg=msg,
branch=import_branch,
other_parents=parents,
)
if options.pristine_tar:
if pristine_orig:
repo.pristine_tar.commit(pristine_orig, upstream_branch)
else:
gbp.log.warn("'%s' not an archive, skipping pristine-tar" % source.path)
tag = repo.version_to_tag(options.upstream_tag, version)
repo.create_tag(name=tag,
msg="Upstream version %s" % version,
commit=commit,
sign=options.sign_tags,
keyid=options.keyid)
if is_empty:
repo.create_branch(options.upstream_branch, rev=commit)
repo.force_head(options.upstream_branch, hard=True)
elif options.merge:
gbp.log.info("Merging to '%s'" % options.debian_branch)
repo.set_branch(options.debian_branch)
try:
#.........这里部分代码省略.........
示例4: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
#.........这里部分代码省略.........
# Export to another build dir if requested:
if options.export_dir:
tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg)
export_source(repo, tree, source, options, tmp_dir, output_dir)
# Run postexport hook
if options.postexport:
Hook('Postexport', options.postexport,
extra_env=md(hook_env,
{'GBP_GIT_DIR': repo.git_dir,
'GBP_TMP_DIR': tmp_dir})
)(dir=tmp_dir)
major = (source.changelog.debian_version if source.is_native()
else source.changelog.upstream_version)
export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major))
gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
# Delayed tarball creation in case a postexport hook is used:
if not source.is_native() and options.postexport:
prepare_upstream_tarball(repo, source.changelog, options, tarball_dir,
output_dir)
if options.export_dir:
build_dir = export_dir
else:
build_dir = repo_dir
if options.prebuild:
Hook('Prebuild', options.prebuild,
extra_env=md(hook_env,
{'GBP_GIT_DIR': repo.git_dir,
'GBP_BUILD_DIR': build_dir})
)(dir=build_dir)
# Finally build the package:
RunAtCommand(options.builder, dpkg_args, shell=True,
extra_env=md(build_env,
{'GBP_BUILD_DIR': build_dir})
)(dir=build_dir)
if options.postbuild:
changes = os.path.abspath("%s/../%s_%s_%s.changes" %
(build_dir,
source.sourcepkg,
source.changelog.noepoch,
changes_file_suffix(dpkg_args)))
gbp.log.debug("Looking for changes file %s" % changes)
Hook('Postbuild', options.postbuild,
extra_env=md(hook_env,
{'GBP_CHANGES_FILE': changes,
'GBP_BUILD_DIR': build_dir})
)()
if options.tag or options.tag_only:
tag = repo.version_to_tag(options.debian_tag, source.changelog.version)
gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag))
if options.retag and repo.has_tag(tag):
repo.delete_tag(tag)
tag_msg = format_str(options.debian_tag_msg,
dict(pkg=source.sourcepkg,
version=source.changelog.version))
repo.create_tag(name=tag,
msg=tag_msg,
sign=options.sign_tags,
commit=head,
keyid=options.keyid)
if options.posttag:
sha = repo.rev_parse("%s^{}" % tag)
Hook('Posttag', options.posttag,
extra_env=md(hook_env,
{'GBP_TAG': tag,
'GBP_BRANCH': branch or '(no branch)',
'GBP_SHA1': sha})
)()
except CommandExecFailed:
retval = 1
except (GbpError, GitRepositoryError) as err:
if str(err):
gbp.log.err(err)
retval = 1
except DebianSourceError as err:
gbp.log.err(err)
source = None
retval = 1
finally:
drop_index()
if not options.tag_only:
if options.export_dir and options.purge and not retval:
RemoveTree(export_dir)()
if source:
summary, msg = gbp.notifications.build_msg(source.changelog,
not retval)
if not gbp.notifications.notify(summary, msg, options.notify):
gbp.log.err("Failed to send notification")
retval = 1
return retval
示例5: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
#.........这里部分代码省略.........
# @KK: This is unnecessary because we are creating a new DebianSource object above now, anyhow.
assert source._changelog is None
# # XXX: Using source.sourcepkg causes debian/changelog to be parsed (and then
# # cached); but we want our post-export hook to be able to change it!
# source._changelog = None
if source.changelog.upstream_version is None and not source.is_native():
raise GbpError('This package is not Debian-native (according to debian/source/format), but the '
'last version number in debian/changelog does not seem to contain a dash (-) to '
'separate the Debian version from the upstream version. (The raw version string '
'is {!r}.)'.format(source.changelog.version))
major = (source.changelog.debian_version if source.is_native()
else source.changelog.upstream_version)
if major is None:
raise GbpError('Cannot determine upstream version from changelog.')
export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major))
gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
# Delayed tarball creation in case a postexport hook is used:
if not source.is_native() and options.postexport:
gbp.log.debug('Preparing upstream tarball (delayed)...')
prepare_upstream_tarball(repo, source.changelog, options, tarball_dir,
output_dir)
if options.export_dir:
build_dir = export_dir
else:
build_dir = repo_dir
if options.prebuild:
Hook('Prebuild', options.prebuild, shell=True,
extra_env={'GBP_GIT_DIR': repo.git_dir,
'GBP_BUILD_DIR': build_dir,
'GBP_PBUILDER_DIST': get_pbuilder_dist(options,
repo,
source.is_native()),
})(dir=build_dir)
setup_pbuilder(options, repo, source.is_native())
# Finally build the package:
RunAtCommand(options.builder, dpkg_args, shell=True,
extra_env={'GBP_BUILD_DIR': build_dir})(dir=build_dir)
if options.postbuild:
changes = os.path.abspath("%s/../%s_%s_%s.changes" %
(build_dir,
source.sourcepkg,
source.changelog.noepoch,
changes_file_suffix(dpkg_args)))
gbp.log.debug("Looking for changes file %s" % changes)
Hook('Postbuild', options.postbuild, shell=True,
extra_env={'GBP_CHANGES_FILE': changes,
'GBP_BUILD_DIR': build_dir})()
if options.tag or options.tag_only:
tag = repo.version_to_tag(options.debian_tag, source.changelog.version)
gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag))
if options.retag and repo.has_tag(tag):
repo.delete_tag(tag)
tag_msg = format_str(options.debian_tag_msg,
dict(pkg=source.sourcepkg,
version=source.changelog.version))
repo.create_tag(name=tag,
msg=tag_msg,
sign=options.sign_tags,
commit=head,
keyid=options.keyid)
if options.posttag:
sha = repo.rev_parse("%s^{}" % tag)
Hook('Posttag', options.posttag, shell=True,
extra_env={'GBP_TAG': tag,
'GBP_BRANCH': branch or '(no branch)',
'GBP_SHA1': sha})()
except CommandExecFailed:
retval = 1
except (GbpError, GitRepositoryError) as err:
if str(err):
gbp.log.err(err)
retval = 1
except DebianSourceError as err:
gbp.log.err(err)
source = None
retval = 1
finally:
drop_index()
if not options.tag_only:
if options.export_dir and options.purge and not retval:
RemoveTree(export_dir)()
if source:
summary, msg = gbp.notifications.build_msg(source.changelog,
not retval)
if not gbp.notifications.notify(summary, msg, options.notify):
gbp.log.err("Failed to send notification")
retval = 1
return retval
示例6: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
retval = 1
branch = None
dest = None
to_push = {
'refs': [],
'tags': [],
}
(options, args) = parse_args(argv)
if not options:
return ExitCodes.parse_error
if len(args) > 2:
gbp.log.err("Only a single remote repository can be given")
elif len(args) == 2:
dest = args[1]
gbp.log.setup(options.color, options.verbose, options.color_scheme)
try:
repo = DebianGitRepository(os.path.curdir, toplevel=False)
except GitRepositoryError:
gbp.log.err("%s is not inside a git repository" % (os.path.abspath('.')))
return 1
try:
source = DebianSource(repo.path)
branch = repo.branch
if not options.ignore_branch:
if branch != options.debian_branch:
gbp.log.err("You are not on branch '%s' but %s" %
(options.debian_branch,
"on '%s'" % branch if branch else 'in detached HEAD state'))
raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")
if not dest:
dest = get_remote(repo, branch)
if options.debian_tag != '':
dtag = repo.version_to_tag(options.debian_tag, source.version)
if repo.has_tag(dtag):
to_push['tags'].append(dtag)
if source.is_releasable() and branch:
ref = 'refs/heads/%s' % branch
to_push['refs'].append((ref, get_push_src(repo, ref, dtag)))
if not source.is_native():
if options.upstream_tag != '':
utag = repo.version_to_tag(options.upstream_tag,
source.upstream_version)
if repo.has_tag(utag):
to_push['tags'].append(utag)
if options.upstream_branch != '':
ref = 'refs/heads/%s' % options.upstream_branch
to_push['refs'].append((ref, get_push_src(repo, ref, utag)))
if options.pristine_tar:
commit = repo.get_pristine_tar_commit(source)
if commit:
ref = 'refs/heads/pristine-tar'
to_push['refs'].append((ref, get_push_src(repo, ref, commit)))
if do_push(repo, [dest], to_push, dry_run=options.dryrun):
retval = 0
else:
gbp.log.err("Failed to push some refs.")
retval = 1
except (GbpError, GitRepositoryError, DebianSourceError) as err:
if str(err):
gbp.log.err(err)
except KeyboardInterrupt:
gbp.log.err("Interrupted. Aborting.")
return retval
示例7: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
dirs = dict(top=os.path.abspath(os.curdir))
needs_repo = False
ret = 0
skipped = False
options, pkg, target = parse_all(argv)
if not options:
return ExitCodes.parse_error
try:
try:
repo = DebianGitRepository('.')
is_empty = repo.is_empty()
(clean, out) = repo.is_clean()
if not clean and not is_empty:
gbp.log.err("Repository has uncommitted changes, commit these first: ")
raise GbpError(out)
except GitRepositoryError:
# no repo found, create one
needs_repo = True
is_empty = True
if options.download:
dsc = download_source(pkg,
dirs=dirs,
unauth=options.allow_unauthenticated)
else:
dsc = pkg
src = DscFile.parse(dsc)
if src.pkgformat not in ['1.0', '3.0']:
raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
if options.verbose:
print_dsc(src)
if needs_repo:
target = target or src.pkg
if os.path.exists(target):
raise GbpError("Directory '%s' already exists. If you want to import into it, "
"please change into this directory otherwise move it away first."
% target)
gbp.log.info("No git repository found, creating one.")
repo = DebianGitRepository.create(target)
os.chdir(repo.path)
repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo)
if repo.bare:
disable_pristine_tar(options, "Bare repository")
dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
upstream = DebianUpstreamSource(src.tgz)
upstream.unpack(dirs['tmp'], options.filters)
for (component, tarball) in src.additional_tarballs.items():
gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
unpack_component_tarball(upstream.unpacked, component, tarball, options.filters)
format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
tag = repo.version_to_tag(format[0], src.upstream_version)
msg = "%s version %s" % (format[1], src.upstream_version)
if repo.find_version(options.debian_tag, src.version):
gbp.log.warn("Version %s already imported." % src.version)
if options.allow_same_version:
gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
move_tag_stamp(repo, options.debian_tag, src.version)
else:
raise SkipImport
if not repo.find_version(format[0], src.upstream_version):
gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
if is_empty:
branch = None
else:
branch = [options.upstream_branch,
options.debian_branch][src.native]
if not repo.has_branch(branch):
if options.create_missing_branches:
gbp.log.info("Creating missing branch '%s'" % branch)
repo.create_branch(branch)
else:
gbp.log.err(no_upstream_branch_msg % branch +
"\nAlso check the --create-missing-branches option.")
raise GbpError
if src.native:
author = get_author_from_changelog(upstream.unpacked)
committer = get_committer_from_author(author, options)
commit_msg = "Import %s\n%s" % (msg, get_changes(upstream.unpacked,
repo,
is_empty,
options.debian_branch))
else:
author = committer = {}
commit_msg = "Import %s" % msg
commit = repo.commit_dir(upstream.unpacked,
commit_msg,
branch,
#.........这里部分代码省略.........
示例8: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
dirs = dict(top=os.path.abspath(os.curdir))
needs_repo = False
ret = 0
skipped = False
options, args = parse_args(argv)
if not options:
return 1
try:
if len(args) != 1:
gbp.log.err("Need to give exactly one package to import. Try --help.")
raise GbpError
else:
pkg = args[0]
if options.download:
dsc = download_source(pkg,
dirs=dirs,
unauth=options.allow_unauthenticated,
no_default_keyrings=options.no_default_keyrings,
keyrings=options.keyring)
else:
dsc = pkg
src = DscFile.parse(dsc)
if src.pkgformat not in [ '1.0', '3.0' ]:
raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
if options.verbose:
print_dsc(src)
try:
repo = DebianGitRepository('.')
is_empty = repo.is_empty()
(clean, out) = repo.is_clean()
if not clean and not is_empty:
gbp.log.err("Repository has uncommitted changes, commit these first: ")
raise GbpError(out)
except GitRepositoryError:
# no repo found, create one
needs_repo = True
is_empty = True
if needs_repo:
gbp.log.info("No git repository found, creating one.")
repo = DebianGitRepository.create(src.pkg)
os.chdir(repo.path)
if repo.bare:
set_bare_repo_options(options)
dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
upstream = DebianUpstreamSource(src.tgz)
upstream.unpack(dirs['tmp'], options.filters)
format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
tag = repo.version_to_tag(format[0], src.upstream_version)
msg = "%s version %s" % (format[1], src.upstream_version)
if repo.find_version(options.debian_tag, src.version):
gbp.log.warn("Version %s already imported." % src.version)
if options.allow_same_version:
gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
move_tag_stamp(repo, options.debian_tag, src.version)
else:
raise SkipImport
if not repo.find_version(format[0], src.upstream_version):
gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
if is_empty:
branch = None
else:
branch = [options.upstream_branch,
options.debian_branch][src.native]
if not repo.has_branch(branch):
if options.create_missing_branches:
gbp.log.info("Creating missing branch '%s'" % branch)
repo.create_branch(branch)
else:
gbp.log.err(no_upstream_branch_msg % branch +
"\nAlso check the --create-missing-branches option.")
raise GbpError
if src.native:
author = get_author_from_changelog(upstream.unpacked)
committer = get_committer_from_author(author, options)
else:
author = committer = {}
commit = repo.commit_dir(upstream.unpacked,
"Imported %s" % msg,
branch,
author=author,
committer=committer)
if not (src.native and options.skip_debian_tag):
repo.create_tag(name=tag,
msg=msg,
#.........这里部分代码省略.........
示例9: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import version_to_tag [as 别名]
def main(argv):
ret = 0
tmpdir = ""
pristine_orig = None
linked = False
(options, args) = parse_args(argv)
if not options:
return 1
try:
try:
repo = DebianGitRepository(".")
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath(".")))
# an empty repo has now branches:
initial_branch = repo.get_branch()
is_empty = False if initial_branch else True
if not repo.has_branch(options.upstream_branch) and not is_empty:
raise GbpError(no_upstream_branch_msg % options.upstream_branch)
(clean, out) = repo.is_clean()
if not clean and not is_empty:
gbp.log.err("Repository has uncommitted changes, commit these first: ")
raise GbpError(out)
# Download the source
if options.download:
source = download_orig(args[0])
else:
source = find_source(options.uscan, args)
if not source:
return ret
(sourcepackage, version) = detect_name_and_version(repo, source, options)
tag = repo.version_to_tag(options.upstream_tag, version)
if repo.has_tag(tag):
raise GbpError("Upstream tag '%s' already exists" % tag)
if repo.bare:
set_bare_repo_options(options)
if not source.is_dir():
tmpdir = tempfile.mkdtemp(dir="../")
source.unpack(tmpdir, options.filters)
gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
if orig_needs_repack(source, options):
gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
(source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters)
(pristine_orig, linked) = prepare_pristine_tar(source.path, sourcepackage, version)
# Don't mess up our repo with git metadata from an upstream tarball
try:
if os.path.isdir(os.path.join(source.unpacked, ".git/")):
raise GbpError("The orig tarball contains .git metadata - giving up.")
except OSError:
pass
try:
upstream_branch = [options.upstream_branch, "master"][is_empty]
filter_msg = ["", " (filtering out %s)" % options.filters][len(options.filters) > 0]
gbp.log.info("Importing '%s' to branch '%s'%s..." % (source.path, upstream_branch, filter_msg))
gbp.log.info("Source package is %s" % sourcepackage)
gbp.log.info("Upstream version is %s" % version)
import_branch = [options.upstream_branch, None][is_empty]
msg = upstream_import_commit_msg(options, version)
if options.vcs_tag:
parents = [repo.rev_parse("%s^{}" % repo.version_to_tag(options.vcs_tag, version))]
else:
parents = None
commit = repo.commit_dir(source.unpacked, msg=msg, branch=import_branch, other_parents=parents)
if options.pristine_tar:
if pristine_orig:
repo.pristine_tar.commit(pristine_orig, upstream_branch)
else:
gbp.log.warn("'%s' not an archive, skipping pristine-tar" % source.path)
repo.create_tag(
name=tag,
msg="Upstream version %s" % version,
commit=commit,
sign=options.sign_tags,
keyid=options.keyid,
)
if is_empty:
repo.create_branch(options.upstream_branch, rev=commit)
repo.force_head(options.upstream_branch, hard=True)
if options.debian_branch != "master":
repo.rename_branch("master", options.debian_branch)
elif options.merge:
debian_branch_merge(repo, tag, version, options)
#.........这里部分代码省略.........