aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-02-26 11:44:36 +0100
committerGuido Günther <agx@sigxcpu.org>2009-02-26 13:48:29 +0100
commite3b76103f7e0e238341303e5941e867278594948 (patch)
tree12f761deda1cfbbe3d853905b325b9642bc044cd
parent660acbe28b4f52f68ae467eb5812897236e8d6e6 (diff)
simplify boolean option handling
-rw-r--r--gbp/config.py14
-rwxr-xr-xgit-buildpackage3
-rwxr-xr-xgit-dch3
-rwxr-xr-xgit-import-dsc3
-rwxr-xr-xgit-import-orig3
5 files changed, 14 insertions, 12 deletions
diff --git a/gbp/config.py b/gbp/config.py
index cbacc9c..9ef668a 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -60,8 +60,6 @@ class GbpOptionParser(OptionParser):
"format string for upstream tags, default is '%(upstream-tag)s'",
'sign-tags':
"sign tags, default is '%(sign-tags)s'",
- 'no-sign-tags':
- "negates sign-tags",
'keyid':
"GPG keyid to sign tags with, default is '%(keyid)s'",
'pristine-tar':
@@ -70,8 +68,6 @@ class GbpOptionParser(OptionParser):
"files to filter out during import (can be given multiple times)",
'git-author':
"use name and email from git-config for changelog trailer, default is '%(git-author)s'",
- 'no-git-author':
- "negates git-author",
}
config_files = [ '/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),
@@ -159,6 +155,11 @@ class GbpOptionParser(OptionParser):
default=self.get_default(option_name, **kwargs),
help=help % self.config, **kwargs)
+ def add_boolean_config_file_option(self, option_name, dest):
+ self.add_config_file_option(option_name=option_name, dest=dest, action="store_true")
+ neg_help = "negates '--%s%s'" % (self.prefix, option_name)
+ self.add_config_file_option(option_name="no-%s" % option_name, dest=dest, help=neg_help, action="store_false")
+
class GbpOptionGroup(OptionGroup):
def add_config_file_option(self, option_name, dest, help=None, **kwargs):
"""
@@ -176,4 +177,9 @@ class GbpOptionGroup(OptionGroup):
default=self.parser.get_default(option_name, **kwargs),
help=help % self.parser.config, **kwargs)
+ def add_boolean_config_file_option(self, option_name, dest):
+ self.add_config_file_option(option_name=option_name, dest=dest, action="store_true")
+ neg_help = "negates '--%s%s'" % (self.parser.prefix, option_name)
+ self.add_config_file_option(option_name="no-%s" % option_name, dest=dest, help=neg_help, action="store_false")
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/git-buildpackage b/git-buildpackage
index a8f2993..bda9d16 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -169,8 +169,7 @@ def main(argv):
help="create a tag after a successful build")
tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
help="don't build, only tag and run the posttag hook")
- tag_group.add_config_file_option(option_name="sign-tags", dest="sign_tags", action="store_true")
- tag_group.add_config_file_option(option_name="no-sign-tags", dest="sign_tags", action="store_false")
+ tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
tag_group.add_config_file_option(option_name="keyid", dest="keyid")
tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
diff --git a/git-dch b/git-dch
index 1b0e34d..4851ea5 100755
--- a/git-dch
+++ b/git-dch
@@ -287,8 +287,7 @@ def main(argv):
help="mark as snapshot build")
version_group.add_option("-N", "--new-version", dest="new_version",
help="use this as base for the new version number")
- version_group.add_config_file_option(option_name="git-author", dest="git_author", action="store_true")
- version_group.add_config_file_option(option_name="no-git-author", dest="git_author", action="store_false")
+ version_group.add_boolean_config_file_option(option_name="git-author", dest="git_author")
commit_group.add_config_file_option(option_name="meta", dest="meta",
help="parse meta tags in commit messages, default is '%(meta)s'", action="store_true")
commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes",
diff --git a/git-import-dsc b/git-import-dsc
index 4cafd21..f9c50cf 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -100,8 +100,7 @@ def main(argv):
parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
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="sign-tags", dest="sign_tags", action="store_true")
- parser.add_config_file_option(option_name="no-sign-tags", dest="sign_tags", action="store_false")
+ parser.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
parser.add_config_file_option(option_name="keyid", dest="keyid")
parser.add_config_file_option(option_name="debian-tag", dest="debian_tag")
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
diff --git a/git-import-orig b/git-import-orig
index 88d544a..e7a344f 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -115,8 +115,7 @@ def main(argv):
help="after import dont do any merging to another branch")
parser.add_config_file_option(option_name="no-dch", dest='no_dch',
help="don't call dch after the import", action="store_true")
- parser.add_config_file_option(option_name="sign-tags", dest="sign_tags", action="store_true")
- parser.add_config_file_option(option_name="no-sign-tags", dest="sign_tags", action="store_false")
+ parser.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
parser.add_config_file_option(option_name="keyid", dest="keyid")
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
parser.add_config_file_option(option_name="filter", dest="filters", action="append")