From 00e73d0480fd62a30636e4e7b20633c56c2ed5f3 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Sat, 6 Mar 2010 11:38:44 +0100 Subject: fedpkg-vcs: Keep alignment for Release/Source0 updates --- fedpkg-vcs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fedpkg-vcs b/fedpkg-vcs index 752fc38..8edc4aa 100755 --- a/fedpkg-vcs +++ b/fedpkg-vcs @@ -199,6 +199,13 @@ class Spec(object): def substitute(self, substitutions): assert not self._saved self._substitutions = substitutions + + def substitute_key(self, key, new_value, string): + pattern = r'(%s:\s+)\S.*' % key + repl = "%s" % r'\g<1>%s' % new_value + + subst = re.sub(pattern, repl, string) + return subst def add_patch(self, filename): patches = self.get_patches() @@ -267,9 +274,9 @@ class Spec(object): if replacement_matched: output.write(line) elif line.startswith('Release:') and self._new_release: - output.write('Release: %s\n' % self._new_release) + output.write(self.substitute_key('Release', self._new_release, line)) elif line.startswith('Source0:') and self._source_archivename: - output.write('Source0: %s\n' % self._source_archivename) + output.write(self.substitute_key('Source0', self._source_archivename, line)) elif line.startswith('%setup') and self._source_dirname: # This is dumb, need to automate this in RPM output.write('%%setup -q -n %s\n' % self._source_dirname) elif line.startswith('BuildRequires:') and not wrote_buildrequires: -- cgit