aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/buildpackage.py
diff options
context:
space:
mode:
authorBen Finney <ben+debian@benfinney.id.au>2017-01-29 13:17:04 +1100
committerGuido Günther <agx@sigxcpu.org>2017-01-29 14:03:50 +0100
commit0fc89bcdb4bbbded6c56e98b54426d34988b857c (patch)
tree57614bbc00748eb13472bbcab27a9ba20b1126ed /gbp/scripts/buildpackage.py
parent22013adfd525378a278676b5f0b4d66834f17afa (diff)
Extract a function to clean the working tree.
Diffstat (limited to 'gbp/scripts/buildpackage.py')
-rwxr-xr-xgbp/scripts/buildpackage.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 7638c855..e5812046 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -240,6 +240,26 @@ def prepare_output_dir(dir):
return output_dir
+def clean_working_tree(options, repo):
+ """
+ Clean the working tree.
+
+ :param options: Program run-time options, as an
+ `optparse.OptionContainer`.
+ :param repo: The Git repository, as a `DebianGitRepository`.
+ :raise GbpError: When the working tree has uncommitted
+ changes.
+ :return: None.
+ """
+ Command(options.cleaner, shell=True)()
+ if not options.ignore_new:
+ (ret, out) = repo.is_clean()
+ if not ret:
+ gbp.log.err("You have uncommitted changes in your source tree:")
+ gbp.log.err(out)
+ raise GbpError("Use --git-ignore-new to ignore.")
+
+
def pristine_tar_prepare_orig_tree(repo, cp, options):
"""Make sure the upstream tree exists
In case of component tarballs we need to recreate a tree for the
@@ -671,13 +691,7 @@ def main(argv):
return 1
try:
- Command(options.cleaner, shell=True)()
- if not options.ignore_new:
- (ret, out) = repo.is_clean()
- if not ret:
- gbp.log.err("You have uncommitted changes in your source tree:")
- gbp.log.err(out)
- raise GbpError("Use --git-ignore-new to ignore.")
+ clean_working_tree(options, repo)
try:
branch = repo.get_branch()