refactor
This commit is contained in:
parent
a40a1ce87d
commit
bc27460564
|
@ -1,6 +1,7 @@
|
||||||
from git import Repo, InvalidGitRepositoryError, Git
|
from git import Repo, InvalidGitRepositoryError, Git
|
||||||
from config import cfg
|
from config import cfg
|
||||||
import logging as log
|
import logging as log
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def check_remote_repo(repo: Repo):
|
def check_remote_repo(repo: Repo):
|
||||||
|
@ -52,15 +53,16 @@ def check_bcp_repo(path: str = cfg.bcp.dir) -> None:
|
||||||
|
|
||||||
|
|
||||||
def add_file_and_commit(file_name: str) -> None:
|
def add_file_and_commit(file_name: str) -> None:
|
||||||
|
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
repo = Repo(cfg.bcp.dir)
|
repo = Repo(cfg.bcp.dir)
|
||||||
if file_name in repo.untracked_files:
|
if file_name in repo.untracked_files:
|
||||||
repo.git.add(file_name)
|
repo.git.add(file_name)
|
||||||
|
repo.index.commit("add %s %s" % (file_name, current_time))
|
||||||
log.info("%r added in repo", file_name)
|
log.info("%r added in repo", file_name)
|
||||||
repo.index.commit("add file %s" % file_name)
|
|
||||||
|
|
||||||
if bool(repo.git.diff(file_name)):
|
if bool(repo.git.diff(file_name)):
|
||||||
repo.index.add([file_name])
|
repo.index.add([file_name])
|
||||||
repo.index.commit("update file %s" % file_name)
|
repo.index.commit("update %s %s" % (file_name, current_time))
|
||||||
log.info("change in %r commited", file_name)
|
log.info("change in %r commited", file_name)
|
||||||
else:
|
else:
|
||||||
log.info("no changed in file %r", file_name)
|
log.info("no changed in file %r", file_name)
|
||||||
|
|
Loading…
Reference in New Issue