1
0
mirror of https://github.com/oskar456/dzonegit.git synced 2024-05-11 05:55:41 +00:00

Add get_increased_serial function

This commit is contained in:
Ondřej Caletka
2018-07-09 10:59:50 +02:00
parent e72403e5d0
commit 1309e9275d
2 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,8 @@
import sys
import subprocess
import re
import time
import datetime
from collections import namedtuple
from hashlib import sha256
from pathlib import Path
@ -100,6 +102,22 @@ def is_serial_increased(old, new):
return 0 < diff < (2**31 - 1)
def get_increased_serial(old):
""" Return increased serial number, automatically recognizing the type. """
old = int(old)
now = int(time.time())
todayserial = int(datetime.date.today().strftime("%Y%m%d00"))
if 1e9 < old < now:
# Serial is unix timestamp
return str(now)
elif 2e9 < old < todayserial:
# Serial is YYYYMMDDnn, updated before today
return str(todayserial)
else:
# No pattern recognized, just increase the number
return str(old + 1)
def get_altered_files(against, diff_filter=None):
""" Return list of changed files. """
cmd = ["git", "diff", "--cached", "--name-only", "-z"]