From 88dd8afc71d209beae779be177071a4587d0b25d Mon Sep 17 00:00:00 2001 From: stransky Date: Sun, 16 Feb 2003 15:28:21 +0100 Subject: [PATCH] J'aurais d commiter plus tt... N. darcs-hash:20030216142821-a279a-3830c365caa8617fa220094a6c73755fc222fd62.gz --- to-cvs-checkins.py | 83 ++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/to-cvs-checkins.py b/to-cvs-checkins.py index e1374e68..51631da7 100755 --- a/to-cvs-checkins.py +++ b/to-cvs-checkins.py @@ -7,6 +7,9 @@ # si ya des lignes trop longues.. # # modif par OS 15/05/00 ajout d'un Reply-To... +# +# Ajouts par NS 13/02/03 : signature qui explique un peu ce qui se passe, et +# création automatique d'un lien vers la page webcvs qui présente le diff. # # Intimement lié à CVSROOT/loginfo # @@ -22,44 +25,68 @@ def LFsplit(s): s=s[75:len(s)+1] else : res=res+s[0:pos]+'\n' - s=s[pos+1:len(s)+1] + s=s[pos+1:len(s)+1] if len(s)>0: - res=res+s + res=res+s return res for uid in os.listdir('/var/cvs'): try: - so = [] + so = [] fi = open('/var/cvs/'+uid,'r') - so.append("From: CVS admin \n" + \ - ("Subject: CVS Commit par %s\n" % uid)+ \ - "Organization: Crans Internet Site\n" + \ - "Newsgroups: crans.cvs-checkins\n" + \ - "Reply-To: Nounous \n" + \ + so.append("From: CVS admin \n" + \ + ("Subject: CVS Commit par %s\n" % uid)+ \ + "Organization: Crans Internet Site\n" + \ + "Newsgroups: crans.cvs-checkins\n" + \ + "Reply-To: Nounous \n" + \ "Followup-To: crans.informatique\n" ) - so.append("MIME-Version: 1.0\n" + \ - "Content-Type: text/plain\n") - so.append("\n") - envoie = 0 - while 1: - s = fi.readline() - if not s: break - envoie = 1 - s=LFsplit(s) - so.append(s) + so.append("MIME-Version: 1.0\n" + \ + "Content-Type: text/plain\n") + so.append("\n") + envoie = 0 + links_base="http://www.crans.org/cgi-bin/cvsweb" + while 1: + s = fi.readline() + if not s: break + envoie = 1 + links=['Liens vers les diffs sur cvsweb :\n'] + diffok = 0 + + # On essaye de créer les liens vers cvsweb automatiquement. + try: + if s[0:3]=="web": + link=string.split(s) + for file in link[1:]: + file=string.split(file,",") + if not string.split(file[0],".")[-1] in ['jpg','jpeg','gif','png']: + links.append("%s/%s/%s.diff?r1=%s&r2=%s\n" % (links_base,link[0],file[0],file[1],file[2])) + diffok = 1 + # S'il y a au moins un diff affichable, on donne le lien. + if diffok: + links.append('\n') + s=string.join(links,'') + else: + s=LFsplit(s) + so.append(s) + except: + so.append(s) + # Avec une signature c'est plus propre. + so.append("\n" + \ + "-- \n" + \ + "Notification automatique des CVS commits sur le site du CR@NS.\n"+ \ + "Voir http://www.crans.org/cgi-bin/cvsweb/web/ pour accéder aux archives CVS complètes.") - # maintenant, on envoie : - - if envoie: - sso = string.join(so,'') - fso = StringIO.StringIO(sso) - nntplib.NNTP('news.crans.org').post(fso) - #print sso - os.unlink('/var/cvs/'+uid) + # maintenant, on envoie : + + if envoie: + sso = string.join(so,'') + fso = StringIO.StringIO(sso) + nntplib.NNTP('news.crans.org').post(fso) + #print sso + os.unlink('/var/cvs/'+uid) except: - raise - + raise