diff options
author | Guido Guenther <agx@sigxcpu.org> | 2007-10-18 15:36:54 +0200 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2007-10-18 15:36:54 +0200 |
commit | 6aba358c925dd3c29db23cbd2123bdcb5950ab70 (patch) | |
tree | e473c4af507ff9374e5b05b983df566bd2a21e08 | |
parent | 34d0347a72f22683a5d32bf07211182db330cf07 (diff) |
pyline and other consistency updates
-rw-r--r-- | gbp/command_wrappers.py | 1 | ||||
-rw-r--r-- | gbp/config.py | 37 | ||||
-rw-r--r-- | gbp/deb_utils.py | 2 | ||||
-rwxr-xr-x | git-buildpackage | 22 | ||||
-rwxr-xr-x | git-dch | 26 | ||||
-rwxr-xr-x | git-import-orig | 22 |
6 files changed, 57 insertions, 53 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 8853f18d..f275474d 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -9,6 +9,7 @@ git-buildpackage and friends import subprocess import sys import os.path +from errors import GbpError class CommandExecFailed(Exception): """Exception raised by the Command class""" diff --git a/gbp/config.py b/gbp/config.py index d1686fa6..244ade5e 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -22,25 +22,25 @@ class GbpOptionParser(OptionParser): @cvar config_files: list of config files we parse @type config_files: list """ - defaults={ 'builder' : 'debuild -i\.git/ -I.git', - 'cleaner' : 'debuild clean', - 'debian-branch' : 'master', - 'upstream-branch' : 'upstream', - 'sign-tags' : '', # empty means False - 'no-create-orig' : '', # empty means False - 'keyid' : '', - 'posttag' : '', - 'debian-tag' : 'debian/%(version)s', - 'upstream-tag' : 'upstream/%(version)s', - 'filter' : '', - 'snapshot-number' : 'snapshot + 1', - 'git-log' : '--no-merges', - 'export-dir' : '', + defaults = { 'builder' : 'debuild -i\.git/ -I.git', + 'cleaner' : 'debuild clean', + 'debian-branch' : 'master', + 'upstream-branch' : 'upstream', + 'sign-tags' : '', # empty means False + 'no-create-orig' : '', # empty means False + 'keyid' : '', + 'posttag' : '', + 'debian-tag' : 'debian/%(version)s', + 'upstream-tag' : 'upstream/%(version)s', + 'filter' : '', + 'snapshot-number' : 'snapshot + 1', + 'git-log' : '--no-merges', + 'export-dir' : '', } - config_files=[ '/etc/git-buildpackage/gbp.conf', - os.path.expanduser('~/.gbp.conf'), - '.gbp.conf', - '.git/gbp.conf' ] + config_files = [ '/etc/git-buildpackage/gbp.conf', + os.path.expanduser('~/.gbp.conf'), + '.gbp.conf', + '.git/gbp.conf' ] def __parse_config_files(self): """parse the possible config files and set appropriate values default values""" @@ -53,6 +53,7 @@ class GbpOptionParser(OptionParser): def __init__(self, command, prefix='', usage=None): self.command = command self.prefix = prefix + self.config = {} self.__parse_config_files() OptionParser.__init__(self, usage=usage) diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py index f4bc854b..1ae8d105 100644 --- a/gbp/deb_utils.py +++ b/gbp/deb_utils.py @@ -20,7 +20,7 @@ def parse_changelog(changelog): if '-' in cp['Version']: upstream_version, cp['Debian-Version'] = cp['Version'].rsplit('-', 1) if ':' in upstream_version: - cp['Epoch'], cp['Upstream-Version'] = upstream_version.split(':',1) + cp['Epoch'], cp['Upstream-Version'] = upstream_version.split(':', 1) else: cp['Upstream-Version'] = upstream_version else: diff --git a/git-buildpackage b/git-buildpackage index 91ce2b3e..2cd26343 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -104,23 +104,23 @@ def main(argv): parser.add_option("--git-ignore-new", action="store_true", dest="ignore_new", default=False, help="build with uncommited changes in the source tree") - parser.add_option("--git-tag", action="store_true", dest="tag", default=False, - help="tag after a successful build") parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") - parser.add_config_file_option(option_name="builder", dest="build_cmd", + parser.add_config_file_option(option_name="builder", dest="builder", help="command to build the package, default is '%(builder)s'") - parser.add_config_file_option(option_name="cleaner", dest="clean_cmd", + parser.add_config_file_option(option_name="cleaner", dest="cleaner", help="command to build the package, default is '%(cleaner)s'") parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch", help="upstream branch, default is '%(upstream-branch)s'") parser.add_config_file_option(option_name="debian-branch", dest='debian_branch', help="branch the debian patch is being developed on, default is '%(debian-branch)s'") - parser.add_config_file_option(option_name="sign-tags", dest="sign_tag", + parser.add_option("--git-tag", action="store_true", dest="tag", default=False, + help="tag after a successful build") + parser.add_config_file_option(option_name="sign-tags", dest="sign_tags", help="sign git tags", action="store_true") parser.add_config_file_option(option_name="no-create-orig", dest="no_create_orig", help="don't create orig.tar.gz", action="store_true") - parser.add_config_file_option(option_name="posttag", dest="posttag_hook", + parser.add_config_file_option(option_name="posttag", dest="posttag", help="hook to execute after a successfull tag operation") parser.add_config_file_option(option_name="keyid", dest="keyid", help="GPG keyid to sign tags with") @@ -147,7 +147,7 @@ def main(argv): try: if not options.ignore_new: - Command(options.clean_cmd, shell=True)() + Command(options.cleaner, shell=True)() (ret, out) = repo.is_clean() if not ret: print >>sys.stderr, "You have uncommitted changes in your source tree:" @@ -196,7 +196,7 @@ def main(argv): if options.export_dir: os.chdir(export_dir) - Command(options.build_cmd, dpkg_args, shell=True)() + Command(options.builder, dpkg_args, shell=True)() if options.tag: try: version = cp['Version'] @@ -204,10 +204,10 @@ def main(argv): raise GbpError, "Can't parse version from changelog" else: print "Tagging %s" % version - GitTag(options.sign_tag, options.keyid)(build_tag(options.debian_tag, version), + GitTag(options.sign_tags, options.keyid)(build_tag(options.debian_tag, version), msg="Debian release %s" % version) - if(options.posttag_hook): - Command(options.posttag_hook, shell=True)() + if(options.posttag): + Command(options.posttag, shell=True)() except CommandExecFailed: retval = 1 @@ -59,11 +59,13 @@ def system(cmd): def add_changelog_entry(msg, author): + "add aa single changelog entry" cmd = 'DEBFULLNAME="%s" dch --append -- "%s"' % (author, msg.replace('"','\"')) system(cmd) def add_changelog_section(msg, distribution): + "add a new changelog section" cmd = "dch --distribution=%s -i %s" % (distribution, msg) system(cmd) @@ -75,10 +77,10 @@ def fixup_trailer(): system(cmd) def head_commit(): - """get the commit id of the last commit on HEAD""" + """get the full sha1 of the last commit on HEAD""" commit = subprocess.Popen([ 'git-log', 'HEAD^..' ], stdout=subprocess.PIPE).stdout - id = commit.readline().split()[-1] - return id + sha = commit.readline().split()[-1] + return sha def snapshot_version(version): @@ -99,7 +101,7 @@ def snapshot_version(version): return release, snapshot -def mangle_changelog(changelog, cp, snapshot, id='unknown'): +def mangle_changelog(changelog, cp, snapshot, sha='unknown'): """Mangle changelog to either add or remove snapshot markers""" try: tmp = '%s.%s' % (changelog, str(snapshot)) @@ -115,7 +117,7 @@ def mangle_changelog(changelog, cp, snapshot, id='unknown'): line = '' if snapshot: - print >>cw, " ** SNAPSHOT build @%s **\n" % id + print >>cw, " ** SNAPSHOT build @%s **\n" % sha if line: print >>cw, line.rstrip() @@ -128,7 +130,8 @@ def mangle_changelog(changelog, cp, snapshot, id='unknown'): raise GbpError, "Error mangling changelog %s" % e -def release(changelog, cp): +def do_release(changelog, cp): + "remove the snapshot header and set the distribution" (release, snapshot) = snapshot_version(cp['Version']) if snapshot: cp['MangledVersion'] = release @@ -137,10 +140,10 @@ def release(changelog, cp): system(cmd) -def snapshot(changelog, next_snapshot): +def do_snapshot(changelog, next_snapshot): """ - Add new snapshot id and banner to most recent changelog section - The next snapshot number is calculated by evaluating next_snapshot + Add new snapshot banner to most recent changelog section. The next snapshot + number is calculated by eval()'ing next_snapshot """ commit = head_commit() @@ -160,7 +163,6 @@ def shortlog_to_dch(changes): commit_re = re.compile('\s+(?P<msg>.*)') author_re = re.compile('(?P<author>.*) \([0-9]+\)') author = 'Unknown' - ret = 0 for line in changes: r = commit_re.match(line) @@ -252,12 +254,12 @@ def main(argv): shortlog_to_dch(changes) fixup_trailer() if options.snapshot: - (snap, version) = snapshot(changelog, options.snapshot_number) + (snap, version) = do_snapshot(changelog, options.snapshot_number) print "Changelog has been prepared for snapshot #%d at %s" % (snap, version) else: print "No changes detected from %s to %s." % (since, until) if options.release: - release(changelog, cp) + do_release(changelog, cp) except GbpError, err: if len(err.__str__()): diff --git a/git-import-orig b/git-import-orig index 54bed776..f5c1b0f0 100755 --- a/git-import-orig +++ b/git-import-orig @@ -50,7 +50,7 @@ def unpack_orig(archive, tmpdir): return unpackArchive.dir -def import_source_tree(repo, orig_dir, version, upstream, filter): +def import_source_tree(repo, orig_dir, version, filter): """import source tree to the current branch""" try: old = set(repo.index_files()) @@ -98,9 +98,9 @@ def main(argv): help="verbose command execution") parser.add_option("--no-merge", dest='merge', action="store_false", default=True, help="after import dont do any merging to another branch") - parser.add_config_file_option(option_name="debian-branch", dest='debian', + parser.add_config_file_option(option_name="debian-branch", dest='debian_branch', help="branch the debian patch is being developed on, default is '%(debian-branch)s'") - parser.add_config_file_option(option_name="upstream-branch", dest="upstream", + parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch", help="upstream branch, default is '%(upstream-branch)s'") parser.add_config_file_option(option_name="sign-tags", dest="sign_tags", help="sign git tags", action="store_true") @@ -112,9 +112,9 @@ def main(argv): help="files to filter out during import") (options, args) = parser.parse_args(argv[1:]) - gitCheckoutMaster = gbpc.GitCheckoutBranch(options.debian) + gitCheckoutMaster = gbpc.GitCheckoutBranch(options.debian_branch) gitShowBranch = gbpc.GitShowBranch() - gitPullUpstream = gbpc.GitPull('.', options.upstream) + gitPullUpstream = gbpc.GitPull('.', options.upstream_branch) try: if options.verbose: @@ -142,7 +142,7 @@ def main(argv): Repository does not have branch '%s' for upstream sources. If there is none see /usr/share/doc/git-buildpackage/manual-html/gbpc.import.convert.html on howto create it otherwise use --upstream-branch to specify it. -""" % options.upstream +""" % options.upstream_upstream raise GbpError if options.version: @@ -173,19 +173,19 @@ create it otherwise use --upstream-branch to specify it. try: if not is_empty: - print "Importing '%s' to branch '%s'..." % (archive, options.upstream) - gbpc.GitCheckoutBranch(options.upstream)() + print "Importing '%s' to branch '%s'..." % (archive, options.upstream_branch) + gbpc.GitCheckoutBranch(options.upstream_branch)() else: print "Initial import of '%s'..." % archive - import_source_tree(repo, orig_dir, version, options.upstream, options.filter) + import_source_tree(repo, orig_dir, version, options.filter) gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version), msg="Upstream version %s" % version) if is_empty: - gbpc.GitBranch()(options.upstream) + gbpc.GitBranch()(options.upstream_branch) elif options.merge: - print "Merging to %s" % options.debian + print "Merging to %s" % options.debian_branch gitCheckoutMaster() gitShowBranch() try: |