Option pour afficher les untracked files une fois par semaine
+ typo
This commit is contained in:
parent
4ca4ffd57d
commit
983a22c6e2
1 changed files with 5 additions and 2 deletions
|
@ -6,6 +6,7 @@ import sendmail
|
|||
import os
|
||||
import argparse
|
||||
import socket
|
||||
import time
|
||||
|
||||
DEFAULTS = {"mail_from" : "root@crans.org",
|
||||
"mail_to" : "root@crans.org",
|
||||
|
@ -36,7 +37,7 @@ def get_status(with_untracked_files=False):
|
|||
def get_status_silentfail(with_untracked_files=False):
|
||||
"""Récupère le status, mais ne renvoie rien si le ``git status`` est essentiellement vide."""
|
||||
out = get_status(with_untracked_files)
|
||||
if all([len(l) == 0 or l.startswith(u"#") for l in out.split(u"\n")]) and not u"adhead" in out:
|
||||
if all([len(l) == 0 or l.startswith(u"#") for l in out.split(u"\n")]) and not u"ahead" in out:
|
||||
return u""
|
||||
else:
|
||||
return out
|
||||
|
@ -59,12 +60,14 @@ if __name__ == "__main__":
|
|||
parser.add_argument("-t", "--to", action="store", type=str, dest="mail_to", help="Destinataire du mail")
|
||||
parser.add_argument("-r", "--repository", action="store", type=str, dest="repo", help="Path du dépôt")
|
||||
parser.add_argument("-u", "--untracked", action="store_true", dest="untracked", help="Affiche aussi les fichiers non trackés")
|
||||
parser.add_argument("-w", "--untracked-weekly", action="store_true", dest="untracked_weekly", help="Affiche les fichiers non trackés si on est Lundi")
|
||||
parser.add_argument("-d", "--debug", action="store_true", dest="debug", help="Affiche le mail au lieu de l'envoyer")
|
||||
parser.set_defaults(**DEFAULTS)
|
||||
args = parser.parse_args()
|
||||
# Si un path de dépôt est fourni, on s'y cd
|
||||
if args.repo:
|
||||
os.chdir(args.repo)
|
||||
out = get_status_silentfail(args.untracked)
|
||||
untracked = args.untracked or (args.untracked_weekly and time.localtime()[6] == 0)
|
||||
out = get_status_silentfail(untracked)
|
||||
if out:
|
||||
send(out, args.mail_from, args.mail_to, args.debug)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue