diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-06-01 23:09:42 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-06-01 23:11:23 +0200 |
commit | 7f580d9da449b13b6bb3c6aaf6f35eba05a35c7e (patch) | |
tree | 499135c324da2e95a383855b760bdc2f5086f2a7 /gbp/scripts/buildpackage.py | |
parent | 16f0309320763a5d32330b97be8ff00b871d1d84 (diff) | |
download | git-buildpackage-7f580d9da449b13b6bb3c6aaf6f35eba05a35c7e.tar.gz git-buildpackage-7f580d9da449b13b6bb3c6aaf6f35eba05a35c7e.tar.bz2 git-buildpackage-7f580d9da449b13b6bb3c6aaf6f35eba05a35c7e.zip |
git-buildpackage: allow to build packages from detached HEAD state
with --git-ignore-branch.
Closes: #661598
Diffstat (limited to 'gbp/scripts/buildpackage.py')
-rwxr-xr-x | gbp/scripts/buildpackage.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 2a3a0928..91a13bb5 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -448,6 +448,7 @@ def main(argv): retval = 0 prefix = "git-" cp = None + branch = None options, gbp_args, dpkg_args = parse_args(argv, prefix) @@ -463,7 +464,6 @@ def main(argv): repo_dir = os.path.abspath(os.path.curdir) try: - branch = repo.get_branch() Command(options.cleaner, shell=True)() if not options.ignore_new: (ret, out) = repo.is_clean() @@ -472,6 +472,13 @@ def main(argv): gbp.log.err(out) raise GbpError, "Use --git-ignore-new to ignore." + try: + branch = repo.get_branch() + except GitRepositoryError: + # Not being on any branch is o.k. with --git-ignore-branch + if not options.ignore_branch: + raise + if not options.ignore_new and not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) @@ -529,7 +536,7 @@ def main(argv): setup_pbuilder(options) # Finally build the package: - RunAtCommand(options.builder, dpkg_args, shell=True, + 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() @@ -553,7 +560,7 @@ def main(argv): sha = repo.rev_parse("%s^{}" % tag) Command(options.posttag, shell=True, extra_env={'GBP_TAG': tag, - 'GBP_BRANCH': branch, + 'GBP_BRANCH': branch or '(no branch)', 'GBP_SHA1': sha})() except CommandExecFailed: retval = 1 |