aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/dch.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-11-27 19:59:32 +0100
committerGuido Günther <agx@sigxcpu.org>2017-11-27 22:49:52 +0100
commit45a0652fa344e63b00970202003ff63ecfa9a2d9 (patch)
tree7ecf3ee349bb100f896d6c6610a64e92db3886b2 /gbp/scripts/dch.py
parentf777a46d612f4d1727f1947f191b46bcacb5f378 (diff)
dch: Create changelog if missing
Closes: #669171 Thanks: Daniel Dehennin for the groundwork on this
Diffstat (limited to 'gbp/scripts/dch.py')
-rw-r--r--gbp/scripts/dch.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index 0d66a801..a086464c 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -304,6 +304,26 @@ def changelog_commit_msg(options, version):
return options.commit_msg % dict(version=version)
+def create_changelog(repo, source, options):
+ try:
+ name = source.control.name
+ except DebianSourceError:
+ raise GbpError("Did not find debian/changelog or debian/source. Is this a Debian package?")
+ version = guess_version_from_upstream(repo, options.upstream_tag,
+ options.upstream_branch, None)
+ return ChangeLog.create(name, version)
+
+
+def maybe_create_changelog(repo, source, options):
+ """
+ Get the changelog or create a new one if it does not exist yet
+ """
+ try:
+ return source.changelog
+ except DebianSourceError:
+ return create_changelog(repo, source, options)
+
+
def build_parser(name):
try:
parser = GbpOptionParserDebian(command=os.path.basename(name),
@@ -452,7 +472,7 @@ def main(argv):
raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")
source = DebianSource('.')
- cp = source.changelog
+ cp = maybe_create_changelog(repo, source, options)
if options.since:
since = options.since