diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-01-06 15:51:43 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-01-06 16:56:27 -0800 |
commit | a90a54aea984cb212bca6aa8faba802f3593e2a5 (patch) | |
tree | 994b628054885449d448ef71125c24624551f675 /src | |
parent | 3eb44a2d4ba388e0b8bb45904c8a7f38889f028a (diff) | |
download | fedora-packager-a90a54aea984cb212bca6aa8faba802f3593e2a5.tar.gz fedora-packager-a90a54aea984cb212bca6aa8faba802f3593e2a5.tar.xz fedora-packager-a90a54aea984cb212bca6aa8faba802f3593e2a5.zip |
Add a clog function
This could probably be done better, but I didn't want to just copy in
the sed script, and my skills at taking sed and converting them into a
python regex are not so hot. So if somebody cares, they can fix it.
Diffstat (limited to 'src')
-rw-r--r-- | src/fedpkg/__init__.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index 7d0d8f4..e296af6 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -241,6 +241,36 @@ class PackageModule: self.rel = self.getrel() self.localarch = self._getlocalarch() + def clog(self): + """Write the latest spec changelog entry to a clog file""" + + # This is a little ugly. We want to find where %changelog starts, + # then only deal with the content up to the first empty newline. + # Then remove any lines that start with $ or %, and then replace + # %% with % + + # This should probably change behavior from dist-cvs and not print + # the first line with the date/name/version as git has that info + # already and it would be redundant. + + cloglines = [] + spec = open(os.path.join(self.path, self.spec), 'r').readlines() + for line in spec: + if line.startswith('%changelog'): + # Grab all the lines below changelog + for line2 in spec[spec.index(line):]: + if line2.startswith('\n'): + break + if line2.startswith('$'): + continue + if line2.startswith('%'): + continue + cloglines.append(line2.replace('%%', '%')) + # Now open the clog file and write out the lines + clogfile = open(os.path.join(self.path, 'clog'), 'w') + clogfile.writelines(cloglines) + return + def compile(self, arch=None, short=False): """Run rpm -bc on a module |