summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgbp/scripts/buildpackage.py2
-rw-r--r--gbp/scripts/common/buildpackage.py25
2 files changed, 14 insertions, 13 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index cc0e6e25..fcc4e2a4 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -577,7 +577,7 @@ def main(argv):
gbp.log.err(err)
retval = 1
finally:
- drop_index()
+ drop_index(repo)
if not options.tag_only:
if options.export_dir and options.purge and not retval:
diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py
index 759a90b1..6483218d 100644
--- a/gbp/scripts/common/buildpackage.py
+++ b/gbp/scripts/common/buildpackage.py
@@ -34,9 +34,6 @@ wc_names = {'WC': {'force': True, 'untracked': True},
'WC.TRACKED': {'force': False, 'untracked': False},
'WC.UNTRACKED': {'force': False, 'untracked': True},
'WC.IGNORED': {'force': True, 'untracked': True}}
-# index file name used to export working copy
-wc_index = ".git/gbp_index"
-
def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level, comp_opts, format='tar'):
"""
@@ -148,21 +145,25 @@ def dump_tree(repo, export_dir, treeish, with_submodules):
return True
+def wc_index(repo):
+ """Get path of the temporary index file used for exporting working copy"""
+ return os.path.join(repo.git_dir, "gbp_index")
+
def write_wc(repo, force=True, untracked=True):
"""write out the current working copy as a treeish object"""
- clone_index()
- repo.add_files(repo.path, force=force, untracked=untracked, index_file=wc_index)
- tree = repo.write_tree(index_file=wc_index)
+ clone_index(repo)
+ repo.add_files(repo.path, force=force, untracked=untracked, index_file=wc_index(repo))
+ tree = repo.write_tree(index_file=wc_index(repo))
return tree
-def drop_index():
+def drop_index(repo):
"""drop our custom index"""
- if os.path.exists(wc_index):
- os.unlink(wc_index)
+ if os.path.exists(wc_index(repo)):
+ os.unlink(wc_index(repo))
-def clone_index():
+def clone_index(repo):
"""Copy the current index file to our custom index file"""
- indexfn = ".git/index"
+ indexfn = os.path.join(repo.git_dir, "index")
if os.path.exists(indexfn):
- shutil.copy2(indexfn, wc_index)
+ shutil.copy2(indexfn, wc_index(repo))