Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 411286 Details for
Bug 559894
Updated-for-git "Package Additions/Removals" mailer scripts
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Replacement python script
find-git-adds-and-removals.py (text/x-python), 3.76 KB, created by
Malcolm Lashley
on 2015-09-07 17:44:29 UTC
(
hide
)
Description:
Replacement python script
Filename:
MIME Type:
Creator:
Malcolm Lashley
Created:
2015-09-07 17:44:29 UTC
Size:
3.76 KB
patch
obsolete
>#!/usr/bin/env python2 ># Authored by Alec Warner <antarus@gentoo.org> ># Significent modifications by Robin H Johnson <robbat2@gentoo.org> ># Modified for Git support by Malcolm Lashley <mlashley@gmail.com> ># Released under the GPL Version 2 ># Copyright Gentoo Foundation 2006 > ># Changelog: Initial release 2006/10/27 ># Git Support 2015/08/25 > >doc = """ ># Purpose: This script analyzes the git log output in an attempt to locate package ># additions and removals. It takes 3 arguments; two of which are optional. It needs ># the path to the repository to read. If a start_date is not provided it will read ># the entire log and match any addition/removal. If you provide a start date it will ># only match things that are after that start_date. If you provide an end date you can ># find matches over date ranges. If an end date is not provided it defaults to now() >""" > >import sys, os, re, time, datetime, subprocess > >new_package = re.compile("^A\s+(.*)\/(.*)\/Manifest$") >removed_package = re.compile("^D\s+(.*)\/(.*)\/Manifest$") >author_re = re.compile("^Author: .*<(.*)@.*>") >date_re = re.compile("^Date:\s+(.*)") >commit_re = re.compile("^commit (.*)") > >class record(object): > def __init__(self, who, date, cp, op, commit ): > """ > Who is a string > date is whatever the crap git outputs for date string :) > cp is a category/package > op is "added", "removed", "moved" > commit is the git sha1 > """ > self.who = who > self.date = date > self.package = cp > self.op = op > self.commit = commit > > def __str__( self ): > #return "Package %s was %s by %s on %s" % (self.package, self.op, self.who, self.date) > return "%s,%s,%s,%s,%s" % (self.package, self.op, self.who, self.date, self.commit) > > def cat (self): > return self.package.split("/")[0] > > def pn (self): > return self.package.split("/")[1] > > def date (self): > return self.date > > def who (self): > return self.who > > def op (self): > return self.op > > def commit (self): > return self.commit > > >def main(): > if (len(sys.argv) < 2): > usage() > sys.exit(1) > > args = sys.argv[1:] > repo_path = args[0] > os.chdir(repo_path) > > if len(args) >= 2: > start_date = ["--after", args[1] ] > else: > start_date = [] > > if len(args) >= 3: > end_date = ["--before", args[2]] > else: > end_date = [] > > p = subprocess.Popen(["git","log","--name-status","--date=iso"] + start_date + end_date,stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > removals = [] > adds = [] > moves = [] > for line in iter(p.stdout.readline,''): > match = commit_re.match(line) > if match: > commit = match.groups()[0] > q = subprocess.Popen(["git","rev-parse","--short",commit],stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > commit = q.stdout.readline() > > match = author_re.match(line) > if match: > who = match.groups()[0] > > match = date_re.match(line) > if match: > date = match.groups()[0] > > match = new_package.match( line ) > if match: > rec = record( who, date, match.groups()[0] + "/" + match.groups()[1], "added", commit ) > adds.append( rec ) > > match = removed_package.match( line ) > if match: > rec = record( who, date, match.groups()[0] + "/" + match.groups()[1], "removed", commit ) > removals.append( rec ) > > print("Removed Packages:") > for pkg in removals: > print(pkg) > > print("Added Packages:") > for pkg in adds: > print(pkg) > print > print("Done.") > >def usage(): > print(sys.argv[0] + " <git repo path> [start date] [end date]") > print("Start date defaults to '0'.") > print("End date defaults to 'now'.") > print("Both dates should be specified as anything git can parse...") > print(doc) > >if __name__ == "__main__": > main() >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 559894
:
411286
|
411288
|
411290
|
411864