Bug#838714: dch: avoid adding section in snapshot mode if distribution is UNRELEASED

2016-10-07 Thread Guido Günther
On Mon, Sep 26, 2016 at 12:50:03PM -0700, Linn Crosetto wrote:
> On Mon, Sep 26, 2016 at 08:19:27AM +0200, Guido Günther wrote:
> [...]
> > This makes sense. Can you add a test to 11_test_dch_main.py to make sure
> > we don't break this again in the future?
> > Cheers,
> 
> I added a test, and have attached the v2 patch. The following are the test
> results with and without the patch applied:

Pushed now. Thanks!
 -- Guido



Bug#838714: dch: avoid adding section in snapshot mode if distribution is UNRELEASED

2016-09-26 Thread Linn Crosetto
On Mon, Sep 26, 2016 at 08:19:27AM +0200, Guido Günther wrote:
[...]
> This makes sense. Can you add a test to 11_test_dch_main.py to make sure
> we don't break this again in the future?
> Cheers,

I added a test, and have attached the v2 patch. The following are the test
results with and without the patch applied:

$ git checkout master
$ git checkout snapshot-fix -- tests/11_test_dch_main.py
$ dpkg-buildpackage -us -uc
[...]
python setup.py nosetests --with-xcoverage
running nosetests
running egg_info
writing gbp.egg-info/PKG-INFO
writing top-level names to gbp.egg-info/top_level.txt
writing dependency_links to gbp.egg-info/dependency_links.txt
writing entry points to gbp.egg-info/entry_points.txt
reading manifest file 'gbp.egg-info/SOURCES.txt'
writing manifest file 'gbp.egg-info/SOURCES.txt'
.SS.FSwitched
 to a new branch 'bar'
.Switched to a new branch 'bar'
...
==
FAIL: Test dch.py like gbp dch script does: snapshot mode with unreleased 
debian version
--
Traceback (most recent call last):
  File "/home/crosetto/dev/git-buildpackage/tests/11_test_dch_main.py", line 
353, in test_dch_main_unreleased_debian_version_with_snapshot
self.assertIsNotNone(header)
AssertionError: unexpectedly None
 >> begin captured logging << 
gbp: info: Changelog last touched at 'f6cf282ecee80f64016056ede581ecf4eb38df65'
gbp: info: Continuing from commit 'f6cf282ecee80f64016056ede581ecf4eb38df65'
gbp: info: Changelog 1.0-2~1.gbp3a1060 (snapshot #1) prepared up to 3a10607
- >> end captured logging << -
[...]
$ git reset HEAD --hard
$ git am v2-0001-dch-avoid-adding-section-in-snapshot-mode-if-dist.patch
Applying: dch: avoid adding section in snapshot mode if distribution is 
UNRELEASED
.git/rebase-apply/patch:18: indent with spaces.
add_section = False
.git/rebase-apply/patch:34: indent with spaces.
elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner:
.git/rebase-apply/patch:35: indent with spaces.
if commits:
.git/rebase-apply/patch:36: indent with spaces.
# the last version was a release and we have pending commits
.git/rebase-apply/patch:37: indent with spaces.
add_section = True
warning: squelched 17 whitespace errors
warning: 22 lines add whitespace errors.
$ dpkg-buildpackage -us -uc
[...]
python setup.py nosetests --with-xcoverage
running nosetests
running egg_info
writing gbp.egg-info/PKG-INFO
writing top-level names to gbp.egg-info/top_level.txt 
writing dependency_links to gbp.egg-info/dependency_links.txt
writing entry points to gbp.egg-info/entry_points.txt 
reading manifest file 'gbp.egg-info/SOURCES.txt'
writing manifest file 'gbp.egg-info/SOURCES.txt'
.SS..Switched
 to a new branch 'bar'
.Switched to a new branch 'bar'
...
[...]

-- Linn
From d5870bc950fc88cd120f832c93477ed560577be6 Mon Sep 17 00:00:00 2001
From: Linn Crosetto 
Date: Wed, 21 Sep 2016 15:59:00 -0600
Subject: [PATCH v2] dch: avoid adding section in snapshot mode if distribution
 is UNRELEASED

When using git-dch in snapshot mode, a section is added without checking
whether the distribution is set to UNRELEASED. If the distribution is
UNRELEASED, the version will be incremented but a new section will not be
added, resulting in a skipped version in the changelog.

Change this behavior to add a new section in snapshot mode only if the
distribution is not set to UNRELEASED.

Signed-off-by: Linn Crosetto 
---
v2
 - dhc.py: set default value for add_section
 - add test_dch_main_unreleased_debian_version_with_snapshot (Guido Günther)

 gbp/scripts/dch.py| 16 
 tests/11_test_dch_main.py | 16 
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index 2ccbacb..d716fba 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -466,6 +466,7 @@ def main(argv):
options=options.git_log.split(" "))
 commits.reverse()
 
+add_section = False
 # add a new changelog section if:
 if (options.new_version or options.bpo or options.nmu or options.qa or
 

Bug#838714: dch: avoid adding section in snapshot mode if distribution is UNRELEASED

2016-09-26 Thread Guido Günther
Hi Linn,
On Fri, Sep 23, 2016 at 03:04:21PM -0600, Linn Crosetto wrote:
> Package: git-buildpackage
> Version: 0.8.3
> Severity: normal
> Tags: patch
> 
> When using gbp dch in snapshot mode, a section is added without checking
> whether the distribution is set to UNRELEASED. If the distribution is
> UNRELEASED, the version will be incremented but the current section will be
> edited, resulting in a skipped version in the changelog. 
> 
> For example, after gbp dch -S -a:
> 
> -git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
> +git-buildpackage (0.8.3+nmu2~1.gbp74f785) UNRELEASED; urgency=medium
> +
> +  ** SNAPSHOT build @74f785ef4ed2e450abc97d882284651e968b7683 **
> 
>* Non-maintainer upload.
> +  * UNRELEASED
> 
> - -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
> + -- Linn Crosetto   Fri, 23 Sep 2016 14:46:07 -0600
> 
>  git-buildpackage (0.8.3) unstable; urgency=medium
> 
> 
> Then after gbp dch --release:
> 
> 
> -git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
> +git-buildpackage (0.8.3+nmu2) unstable; urgency=medium
> 
>* Non-maintainer upload.
> +  * dch: avoid adding section in snapshot mode if distribution is UNRELEASED
> 
> - -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
> + -- Linn Crosetto   Fri, 23 Sep 2016 14:47:01 -0600
> 
> 
> I have included a patch to changing this behavior to add a new section in
> snapshot mode only if the distribution is not set to UNRELEASED.
> 
> An example of the new behavior, after gbp dch -S -a:
> 
> 
> -git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
> +git-buildpackage (0.8.3+nmu1~1.gbp74f785) UNRELEASED; urgency=medium
> +
> +  ** SNAPSHOT build @74f785ef4ed2e450abc97d882284651e968b7683 **
>  
>* Non-maintainer upload.
> 
> 
> Then after gbp dch --release:
> 
> 
> -git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
> +git-buildpackage (0.8.3+nmu1) unstable; urgency=medium
>  
>* Non-maintainer upload.
> +  * dch: avoid adding section in snapshot mode if distribution is UNRELEASED
>  
> - -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
> + -- Linn Crosetto   Fri, 23 Sep 2016 20:56:40 +
>  
>  git-buildpackage (0.8.3) unstable; urgency=medium
> 
> 
> Thanks.

> >From 8f6ae69c2e1a432d8c4e26d5997eddc5bc7ae162 Mon Sep 17 00:00:00 2001
> From: Linn Crosetto 
> Date: Wed, 21 Sep 2016 15:59:00 -0600
> Subject: [PATCH] dch: avoid adding section in snapshot mode if distribution is
>  UNRELEASED
> 
> When using git-dch in snapshot mode, a section is added without checking
> whether the distribution is set to UNRELEASED. If the distribution is
> UNRELEASED, the version will be incremented but a new section will not be
> added, resulting in a skipped version in the changelog.
> 
> Change this behavior to add a new section in snapshot mode only if the
> distribution is not set to UNRELEASED.
> 
> Signed-off-by: Linn Crosetto 
> ---
>  gbp/scripts/dch.py | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
> index 2ccbacb..f9f60c0 100644
> --- a/gbp/scripts/dch.py
> +++ b/gbp/scripts/dch.py
> @@ -483,12 +483,13 @@ def main(argv):
>  version_change['version'] = options.new_version
>  # the user wants to force a new version
>  add_section = True
> -elif cp['Distribution'] != "UNRELEASED" and not 
> found_snapshot_banner and commits:
> -# the last version was a release and we have pending commits
> -add_section = True
> -elif options.snapshot and not found_snapshot_banner:
> -# the user want to switch to snapshot mode
> -add_section = True
> +elif cp['Distribution'] != "UNRELEASED" and not 
> found_snapshot_banner:
> +if commits:
> +# the last version was a release and we have pending commits
> +add_section = True
> +if options.snapshot:
> +# the user want to switch to snapshot mode
> +add_section = True
>  else:
>  add_section = False

This makes sense. Can you add a test to 11_test_dch_main.py to make sure
we don't break this again in the future?
Cheers,
 -- Guido



Bug#838714: dch: avoid adding section in snapshot mode if distribution is UNRELEASED

2016-09-23 Thread Linn Crosetto
Package: git-buildpackage
Version: 0.8.3
Severity: normal
Tags: patch

When using gbp dch in snapshot mode, a section is added without checking
whether the distribution is set to UNRELEASED. If the distribution is
UNRELEASED, the version will be incremented but the current section will be
edited, resulting in a skipped version in the changelog. 

For example, after gbp dch -S -a:

-git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
+git-buildpackage (0.8.3+nmu2~1.gbp74f785) UNRELEASED; urgency=medium
+
+  ** SNAPSHOT build @74f785ef4ed2e450abc97d882284651e968b7683 **

   * Non-maintainer upload.
+  * UNRELEASED

- -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
+ -- Linn Crosetto   Fri, 23 Sep 2016 14:46:07 -0600

 git-buildpackage (0.8.3) unstable; urgency=medium


Then after gbp dch --release:


-git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
+git-buildpackage (0.8.3+nmu2) unstable; urgency=medium

   * Non-maintainer upload.
+  * dch: avoid adding section in snapshot mode if distribution is UNRELEASED

- -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
+ -- Linn Crosetto   Fri, 23 Sep 2016 14:47:01 -0600


I have included a patch to changing this behavior to add a new section in
snapshot mode only if the distribution is not set to UNRELEASED.

An example of the new behavior, after gbp dch -S -a:


-git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
+git-buildpackage (0.8.3+nmu1~1.gbp74f785) UNRELEASED; urgency=medium
+
+  ** SNAPSHOT build @74f785ef4ed2e450abc97d882284651e968b7683 **
 
   * Non-maintainer upload.


Then after gbp dch --release:


-git-buildpackage (0.8.3+nmu1) UNRELEASED; urgency=medium
+git-buildpackage (0.8.3+nmu1) unstable; urgency=medium
 
   * Non-maintainer upload.
+  * dch: avoid adding section in snapshot mode if distribution is UNRELEASED
 
- -- Linn Crosetto   Fri, 23 Sep 2016 18:51:37 +
+ -- Linn Crosetto   Fri, 23 Sep 2016 20:56:40 +
 
 git-buildpackage (0.8.3) unstable; urgency=medium


Thanks.
>From 8f6ae69c2e1a432d8c4e26d5997eddc5bc7ae162 Mon Sep 17 00:00:00 2001
From: Linn Crosetto 
Date: Wed, 21 Sep 2016 15:59:00 -0600
Subject: [PATCH] dch: avoid adding section in snapshot mode if distribution is
 UNRELEASED

When using git-dch in snapshot mode, a section is added without checking
whether the distribution is set to UNRELEASED. If the distribution is
UNRELEASED, the version will be incremented but a new section will not be
added, resulting in a skipped version in the changelog.

Change this behavior to add a new section in snapshot mode only if the
distribution is not set to UNRELEASED.

Signed-off-by: Linn Crosetto 
---
 gbp/scripts/dch.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index 2ccbacb..f9f60c0 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -483,12 +483,13 @@ def main(argv):
 version_change['version'] = options.new_version
 # the user wants to force a new version
 add_section = True
-elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner and commits:
-# the last version was a release and we have pending commits
-add_section = True
-elif options.snapshot and not found_snapshot_banner:
-# the user want to switch to snapshot mode
-add_section = True
+elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner:
+if commits:
+# the last version was a release and we have pending commits
+add_section = True
+if options.snapshot:
+# the user want to switch to snapshot mode
+add_section = True
 else:
 add_section = False
 
-- 
2.8.0.rc3