summaryrefslogtreecommitdiff
path: root/git-import-orig
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-06-27 12:22:33 -0400
committerGuido Guenther <agx@sigxcpu.org>2007-06-27 12:22:33 -0400
commit6af72fd593372f27cfc7ef3e0dac262a142a1156 (patch)
tree5d56e603d25606c4778cfc4fc677eebf88c52a16 /git-import-orig
parent70c70759f05bf20dbab526f6a3ecfb4f27419502 (diff)
parentb014ad23d94771e736a6df194138b2c89219d472 (diff)
downloadgit-buildpackage-6af72fd593372f27cfc7ef3e0dac262a142a1156.tar.gz
git-buildpackage-6af72fd593372f27cfc7ef3e0dac262a142a1156.tar.bz2
git-buildpackage-6af72fd593372f27cfc7ef3e0dac262a142a1156.zip
Merge branch 'master' into bpo-etchdebian/0.3.2.bpo.1
Conflicts: debian/changelog
Diffstat (limited to 'git-import-orig')
-rwxr-xr-xgit-import-orig29
1 files changed, 20 insertions, 9 deletions
diff --git a/git-import-orig b/git-import-orig
index cff1fc61..ee986beb 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -29,6 +29,7 @@ from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
from gbp.config import GbpOptionParser
from gbp.errors import GbpError
+
def cleanup_tmp_tree(tree):
"""remove a tree of temporary files"""
try:
@@ -49,10 +50,9 @@ def unpack_orig(archive, tmpdir):
return unpackArchive.dir
-def import_to_upstream_branch(repo, orig_dir, version, upstream, filter):
- """import source to the upstream branch"""
+def import_source_tree(repo, orig_dir, version, upstream, filter):
+ """import source tree to the current branch"""
try:
- gbpc.GitCheckoutBranch(upstream)()
old = set(repo.index_files())
new = set(gbpc.copy_from(orig_dir, filter))
gbpc.GitAdd()(['.'])
@@ -74,6 +74,7 @@ def get_version(tgz):
if m:
return m.group('version')
+
def main(argv):
ret = 0
tmpdir = ''
@@ -120,7 +121,13 @@ def main(argv):
except GitRepositoryError:
raise GbpError, "%s is not a git repository" % (os.path.abspath('.'))
- if not repo.has_branch(options.upstream):
+ # an empty repo has now branches:
+ if repo.get_branch():
+ is_empty = False
+ else:
+ is_empty = True
+
+ if not repo.has_branch(options.upstream) and not is_empty:
print >>sys.stderr, """
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
@@ -141,7 +148,7 @@ create it otherwise use --upstream-branch to specify it.
raise GbpError
(clean, out) = repo.is_clean()
- if not clean:
+ if not clean and not is_empty:
print >>sys.stderr, "Repository has uncommitted changes, commit these first: "
raise GbpError, out
@@ -151,16 +158,20 @@ create it otherwise use --upstream-branch to specify it.
tmpdir = tempfile.mkdtemp(dir='../')
unpack_orig(archive, tmpdir)
if options.verbose:
- print "Unpacked orig to %s" % tmpdir
+ print "Unpacked %s to '%s'" % (archive , tmpdir)
orig_dir = glob.glob(tmpdir+'/*')[0]
try:
- print "Importing %s to upstream branch..." % archive
- import_to_upstream_branch(repo, orig_dir, version, options.upstream, options.filter)
+ if not is_empty:
+ print "Importing '%s' to branch '%s'..." % (archive, options.upstream)
+ gbpc.GitCheckoutBranch(options.upstream)()
+ else:
+ print "Initial import of '%s'..." % archive
+ import_source_tree(repo, orig_dir, version, options.upstream, options.filter)
gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version),
msg="Upstream version %s" % version)
- if options.merge:
+ if options.merge and not is_empty:
print "Merging to %s" % options.debian
gitCheckoutMaster()
gitShowBranch()