|
|
|
@ -18,6 +18,7 @@ import os
|
|
|
|
|
import sys
|
|
|
|
|
import re
|
|
|
|
|
from os import path
|
|
|
|
|
import datetime
|
|
|
|
|
from calculate.lib.cl_template import SystemIni
|
|
|
|
|
from calculate.lib.cl_log import log
|
|
|
|
|
from calculate.lib.datavars import (Variable, VariableError,
|
|
|
|
@ -1811,8 +1812,10 @@ class VariableClUpdateOnedepthSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Удлять лишние файлы из репозиториев (например созданные пользователем)
|
|
|
|
|
"""
|
|
|
|
|
type = "bool"
|
|
|
|
|
value = "off"
|
|
|
|
|
type = "bool3"
|
|
|
|
|
value = 'auto'
|
|
|
|
|
max_interval = 'cl_update_onedepth_interval'
|
|
|
|
|
check_after = 'cl_update_onedepth_interval'
|
|
|
|
|
|
|
|
|
|
opt = ["--one-depth", "-1"]
|
|
|
|
|
|
|
|
|
@ -1820,6 +1823,43 @@ class VariableClUpdateOnedepthSet(Variable):
|
|
|
|
|
self.label = _("Clear the history of repositories")
|
|
|
|
|
self.help = _("clear the history of repositories")
|
|
|
|
|
|
|
|
|
|
def get_oldest_history(self, rep):
|
|
|
|
|
try:
|
|
|
|
|
with open(f'{rep}/.git/logs/HEAD') as inf:
|
|
|
|
|
oldest_timestamp = int(inf.readline().split()[4])
|
|
|
|
|
date = datetime.datetime.fromtimestamp(oldest_timestamp)
|
|
|
|
|
return datetime.datetime.now() - date
|
|
|
|
|
except OSError:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
def set(self, value):
|
|
|
|
|
try:
|
|
|
|
|
if value == 'auto' or value is None:
|
|
|
|
|
rep_path = self.Get('cl_update_rep_path')
|
|
|
|
|
for rep in rep_path:
|
|
|
|
|
if self.get_oldest_history(rep).days > int(self.Get(self.max_interval)):
|
|
|
|
|
self.value = 'on'
|
|
|
|
|
return 'on'
|
|
|
|
|
self.value = 'off'
|
|
|
|
|
return 'off'
|
|
|
|
|
except:
|
|
|
|
|
return 'off'
|
|
|
|
|
self.value = value
|
|
|
|
|
return self.value
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.value == 'auto' or self.value is None:
|
|
|
|
|
return self.set(self.value)
|
|
|
|
|
return self.value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateOnedepthInterval(Variable):
|
|
|
|
|
default_value = 0
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if not self.value:
|
|
|
|
|
return self.default_value
|
|
|
|
|
return self.value
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateEixRepositories(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|