aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2006-12-10 16:07:37 +0100
committerGuido Guenther <agx@bogon.sigxcpu.org>2006-12-10 16:07:37 +0100
commitff7797932f04a625d92d7e63e9af5bfbe1076a9d (patch)
treea17fcd130ef15482f6a4823b95b50ac2043b7a46
parent093704c9c7e16d71659c49661ce91c605bfabd45 (diff)
git-buildpackage: detect the branch we're on and bail out if it's not the debian branchdebian/0.2.18
-rw-r--r--debian/changelog8
-rw-r--r--docs/manpages/git-buildpackage.sgml46
-rw-r--r--docs/manpages/git-import-dsc.sgml26
-rw-r--r--docs/manpages/git-import-orig.sgml26
-rw-r--r--docs/manpages/manpages.ent21
-rwxr-xr-xgit-buildpackage9
-rw-r--r--git_buildpackage/config.py1
-rw-r--r--git_buildpackage/git_utils.py28
8 files changed, 90 insertions, 75 deletions
diff --git a/debian/changelog b/debian/changelog
index 27ac236..abc0dd4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+git-buildpackage (0.2.18) experimental; urgency=low
+
+ * git-buildpackage: detect the branch we're on and bail out if it's not the
+ debian branch
+ * doc updates
+
+ -- Guido Guenther <agx@sigxcpu.org> Sun, 10 Dec 2006 14:57:35 +0100
+
git-buildpackage (0.2.17) experimental; urgency=low
* fix wrong default debian branch
diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml
index 0a151e0..bf473af 100644
--- a/docs/manpages/git-buildpackage.sgml
+++ b/docs/manpages/git-buildpackage.sgml
@@ -24,12 +24,14 @@
<refsynopsisdiv>
<cmdsynopsis>
&git-buildpackage;
-
<arg><option>--git-ignore-new</option></arg>
<arg><option>--git-tag</option></arg>
<arg><option>--git-verbose</option></arg>
<arg><option>--upstream-branch=<replaceable>branch_name</replaceable></option></arg>
+ <arg><option>--debian-branch=<replaceable>branch_name</replaceable></option></arg>
<arg><option>--git-builder=<replaceable>BUILD_CMD</replaceable></option></arg>
+ <arg><option>--git-sign-tags</option></arg>
+ <arg><option>--git-keyid</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
@@ -44,6 +46,12 @@
<listitem><para>Verify that it is being executed from the
proper location.</para>
</listitem>
+ <listitem><para>Verify that the reopository doesn't contain any
+ uncommitted source changes.</para>
+ </listitem>
+ <listitem><para>Verify that it is being executed from the
+ correct branch.</para>
+ </listitem>
<listitem><para>Build an orig.tar.gz if it doesn't exist.</para>
</listitem>
<listitem><para>Call <application>debuild</application> (1)
@@ -80,8 +88,6 @@
<para>Use <replaceable>BUILD_CMD</replaceable> instead of <command>debuild</command></para>
</listitem>
</varlistentry>
- </variablelist>
- <variablelist>
<varlistentry>
<term><option>--git-verbose</option>
</term>
@@ -96,34 +102,22 @@
<para>Branch to build the orig.tar.gz from. Default is 'upstream'</para>
</listitem>
</varlistentry>
- </variablelist>
- </refsect1>
- <refsect1>
- <title>CONFIGURATION FILES</title>
- Three configuration files are parsed:
- <variablelist>
<varlistentry>
- <term>/etc/git-buildpacakge/gbp.conf</term>
- </varlistentry>
- <varlistitem>- system wide configuraton</varlistitem>
- <varlistentry>
- <term>~/.gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per user configuration
+ <term><option>--git-debian-branch</option>=<replaceable>branch_name</replaceable>
+ </term>
+ <listitem>
+ <para>If you're not on this branch when invoking &git-buildpackage;
+ it will fail. Default is 'master'. This option will be ignored
+ when using <option>--git-ignore-new</option>.
+ </para>
+ </listitem>
</varlistentry>
- <varlistentry>
- <term>\.git/gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per repository configuration
- </varlistentry>
</variablelist>
- <para>
- See /etc/git-buildpacakge/gbp.conf for an example.
- </para>
</refsect1>
<refsect1>
+ &man.git.config-files;
+ <para>All options in the config files are specified without the 'git-' prefix.
+ <refsect1>
<title>SEE ALSO</title>
<para>git-import-dsc (1), git-import-orig (1), debuild (1), git (1)</para>
diff --git a/docs/manpages/git-import-dsc.sgml b/docs/manpages/git-import-dsc.sgml
index 7dec2f6..42c0fa7 100644
--- a/docs/manpages/git-import-dsc.sgml
+++ b/docs/manpages/git-import-dsc.sgml
@@ -28,6 +28,8 @@
<arg><option>--verbose</option></arg>
<arg><option>--upstream-branch=<replaceable>branch_name</replaceable></option></arg>
+ <arg><option>--sign-tags</option></arg>
+ <arg><option>--keyid</option></arg>
<arg choice="plain"><replaceable>dsc_file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -61,29 +63,7 @@
</variablelist>
</refsect1>
<refsect1>
- <title>CONFIGURATION FILES</title>
- Three configuration files are parsed:
- <variablelist>
- <varlistentry>
- <term>/etc/git-buildpacakge/gbp.conf</term>
- </varlistentry>
- <varlistitem>- system wide configuraton</varlistitem>
- <varlistentry>
- <term>~/.gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per user configuration
- </varlistentry>
- <varlistentry>
- <term>\.git/gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per repository configuration
- </varlistentry>
- </variablelist>
- <para>
- See /etc/git-buildpacakge/gbp.conf for an example.
- </para>
+ &man.git.config-files;
</refsect1>
<refsect1>
<title>SEE ALSO</title>
diff --git a/docs/manpages/git-import-orig.sgml b/docs/manpages/git-import-orig.sgml
index 0e50739..7bc169a 100644
--- a/docs/manpages/git-import-orig.sgml
+++ b/docs/manpages/git-import-orig.sgml
@@ -30,6 +30,8 @@
<arg><option>--upstream-branch=<replaceable>branch_name</replaceable></option></arg>
<arg><option>--debian-branch=<replaceable>branch_name</replaceable></option></arg>
<arg><option>--upstream-version=<replaceable>version</replaceable></option></arg>
+ <arg><option>--sign-tags</option></arg>
+ <arg><option>--keyid</option></arg>
<arg choice="plain"><replaceable>tar_gz</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -85,29 +87,7 @@
</variablelist>
</refsect1>
<refsect1>
- <title>CONFIGURATION FILES</title>
- Three configuration files are parsed:
- <variablelist>
- <varlistentry>
- <term>/etc/git-buildpacakge/gbp.conf</term>
- </varlistentry>
- <varlistitem>- system wide configuraton</varlistitem>
- <varlistentry>
- <term>~/.gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per user configuration
- </varlistentry>
- <varlistentry>
- <term>\.git/gbp.conf</term>
- </varlistentry>
- <varlistentry>
- - per repository configuration
- </varlistentry>
- </variablelist>
- <para>
- See /etc/git-buildpacakge/gbp.conf for an example.
- </para>
+ &man.git.config-files;
</refsect1>
<refsect1>
<title>SEE ALSO</title>
diff --git a/docs/manpages/manpages.ent b/docs/manpages/manpages.ent
index d024c6a..43f2a24 100644
--- a/docs/manpages/manpages.ent
+++ b/docs/manpages/manpages.ent
@@ -1,3 +1,24 @@
<!ENTITY man.git.importorig SYSTEM "git-import-orig.sgml">
<!ENTITY man.git.importdsc SYSTEM "git-import-dsc.sgml">
<!ENTITY man.git.buildpackage SYSTEM "git-buildpackage.sgml">
+<!ENTITY man.git.config-files "
+ <title>CONFIGURATION FILES</title>
+ Three configuration files are parsed to set defaults for the above
+ commandline arguments:
+ <variablelist>
+ <varlistentry>
+ <term>/etc/git-buildpacakge/gbp.conf</term>
+ <listitem><para>system wide configuraton</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>~/.gbp.conf</term>
+ <listitem><para>per user configuration</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>.git/gbp.conf</term>
+ <listitem><para>per repository configuration</para></listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ See /etc/git-buildpacakge/gbp.conf for an example.
+ </para>">
diff --git a/git-buildpackage b/git-buildpackage
index 25c4a8b..9f1c6d9 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -63,6 +63,8 @@ def main(argv):
help="command to build the package e.g. default is '%(builder)s'")
parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
help="upstream branch, default is '%(upstream-branch)s'")
+ parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
+ help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
parser.add_config_file_option(option_name="sign-tags", dest="sign_tag",
help="sign git tags", action="store_true")
parser.add_config_file_option(option_name="keyid", dest="keyid",
@@ -85,11 +87,18 @@ def main(argv):
print >>sys.stderr, out
print >>sys.stderr, "Use --git-ignore-new to ignore."
return 1
+ branch=get_repository_branch('.')
+ if branch != options.debian_branch and not options.ignore_new:
+ print >>sys.stderr, "You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)
+ print >>sys.stderr, "Use --git-ignore-new to ignore or --git-debian-branch to set the branch name."
+ return 1
+
cp = parse_changelog('debian/changelog')
if not is_native(cp) and not has_orig(cp, output_dir):
print "%s does not exist, creating from branch %s" % (orig_file(cp), options.upstream_branch)
if not create_orig(cp, output_dir, options.upstream_branch):
return 1
+
Command(options.build_cmd,[ '-i.git', '-I.git' ]+dpkg_args)()
if options.tag:
try:
diff --git a/git_buildpackage/config.py b/git_buildpackage/config.py
index a6f3ff7..e1fde15 100644
--- a/git_buildpackage/config.py
+++ b/git_buildpackage/config.py
@@ -25,6 +25,7 @@ class GBPOptionParser(OptionParser):
defaults={ 'builder' : 'debuild',
'debian-branch' : 'master',
'upstream-branch' : 'upstream',
+ 'upstream-branch' : 'upstream',
'sign-tags' : '', # empty means False
'keyid' : '',
}
diff --git a/git_buildpackage/git_utils.py b/git_buildpackage/git_utils.py
index 59f80f2..1cd5e6d 100644
--- a/git_buildpackage/git_utils.py
+++ b/git_buildpackage/git_utils.py
@@ -1,12 +1,16 @@
# -*- coding: utf-8 -*-
+#
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
"""provides some git repository related helpers"""
import subprocess
import os.path
+import re
+
def is_repository_clean(path):
"""Does the repository at path contain any uncommitted modifications"""
+ clean_msg='nothing to commit'
try:
curdir=os.path.abspath(os.path.curdir)
os.chdir(path)
@@ -15,13 +19,30 @@ def is_repository_clean(path):
popen = subprocess.Popen(['git','status'], stdout=subprocess.PIPE)
popen.wait()
out=popen.stdout.readlines()
- if out[0].strip() != 'nothing to commit':
- ret=False
- else:
+ if out[0].strip() == clean_msg:
+ ret=True
+ elif out[0].startswith('#') and out[1].strip() == clean_msg:
ret=True
+ else:
+ ret=False
os.chdir(curdir)
return (ret, "".join(out))
+
+def get_repository_branch(path):
+ """on what branch is the repository at path?"""
+ try:
+ curdir=os.path.abspath(os.path.curdir)
+ os.chdir(path)
+ except OSError:
+ return None
+ popen = subprocess.Popen(['git','branch'], stdout=subprocess.PIPE)
+ popen.wait()
+ for line in popen.stdout:
+ if line.startswith('*'):
+ return line.split(' ',1)[1].strip()
+
+
def is_repository(path):
"""Is there a git repository at path"""
if not path:
@@ -32,6 +53,7 @@ def is_repository(path):
return False
return True
+
def sanitize_version(version):
"""sanitize a version so git accepts it as a tag"""
if ':' in version: # strip of any epochs