Blob Blame History Raw
From d1a0ec893fc609795c6553553dc274105bd0d389 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu>
Date: Mon, 17 Aug 2015 14:04:08 +0200
Subject: [PATCH 24/26] Add a snippet generating RPM SPEC %changelog line.

https://bugzilla.gnome.org/show_bug.cgi?id=732813
---
 plugins/snippets/Makefile.am      |  1 +
 plugins/snippets/data/rpmspec.xml | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 plugins/snippets/data/rpmspec.xml

diff --git a/plugins/snippets/Makefile.am b/plugins/snippets/Makefile.am
index f4f5d0c..20c8ccc 100644
--- a/plugins/snippets/Makefile.am
+++ b/plugins/snippets/Makefile.am
@@ -44,6 +44,7 @@ dist_plugins_snippets_snippets_DATA =		\
 	plugins/snippets/data/perl.xml		\
 	plugins/snippets/data/php.xml		\
 	plugins/snippets/data/python.xml	\
+	plugins/snippets/data/rpmspec.xml		\
 	plugins/snippets/data/ruby.xml		\
 	plugins/snippets/data/sh.xml		\
 	plugins/snippets/data/snippets.xml	\
diff --git a/plugins/snippets/data/rpmspec.xml b/plugins/snippets/data/rpmspec.xml
new file mode 100644
index 0000000..eb3396d
--- /dev/null
+++ b/plugins/snippets/data/rpmspec.xml
@@ -0,0 +1,22 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!-- requires rpm-python package installed -->
+<snippets language="rpmspec">
+  <snippet id="ch">
+    <text><![CDATA[$<
+import rpm
+import datetime
+
+spec = rpm.spec($GEDIT_CURRENT_DOCUMENT_PATH)
+date = datetime.date.today().strftime("%a %b %d %Y")
+headers = spec.packages[0].header
+version = headers['Version']
+release = ".".join(headers['Release'].split(".")[:-1])
+packager = headers['Packager']
+newheader = "* %s %s - %s-%s\n- " % (date, packager, version, release)
+return newheader
+>
+]]></text>
+    <tag>ch</tag>
+    <description>changelog entry</description>
+  </snippet>
+</snippets>
-- 
1.8.3.1