Managers.Git in progress

dev-linux
Ivan Maslov 3 years ago
parent ebdb5d5075
commit 628cdc593c

@ -4,12 +4,14 @@ import os
from .. import __Orchestrator__
from . import Process
from typing import List
class Git():
mAgentHostNameStr = None
mAgentUserNameStr = None
mAbsPathStr = None
mProcessList = [] # List of the key turples of the Process instance
mProcessList: List[Process] = [] # List of the key turples of the Process instance
def __init__(self, inAgentHostNameStr=None, inAgentUserNameStr=None, inGitPathStr=""):
"""
@ -43,9 +45,25 @@ class Git():
else:
raise Exception(f"Process with current key is already exists in Git process list.")
def ProcessListSaveStopSafe(self):
"""
Save the state and do the stop safe for the all processes
"""
for lProcessItem in self.mProcessList:
lProcessItem.StatusSave()
lProcessItem.StopSafe()
def ProcessListRestore(self):
"""
Restore the process state for the all processes
"""
for lProcessItem in self.mProcessList:
lProcessItem.StatusRestore()
def __OSCMDShell__(self, inCMDStr):
"""
Detect the way of use and send the cmd
Detect the way of use and send the cmd. Wait for command execution!
:return: None is not exists
"""
@ -82,19 +100,62 @@ class Git():
lIsLastBool = True
return lIsLastBool
def BranchRevLastGet(self, inBranchLocalStr: str, inBranchRemoteStr: str, inBranchRestoreBool: bool = True):
"""Do some action to get the last revision
:param inBranchLocalStr: [description]
:type inBranchLocalStr: str
:param inBranchRemoteStr: [description]
:type inBranchRemoteStr: str
"""
# check if the correct revision
if self.BranchRevIsLast(inBranchLocalStr=inBranchLocalStr, inBranchRemoteStr=inBranchRemoteStr) == False:
lBranchNameCurrentStr = self.BranchNameGet()
# reset all changes in local folder
self.Clear()
# checkout
self.BranchCheckout(inBranchNameStr=inBranchLocalStr)
# merge
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git merge {inBranchRemoteStr}"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
if inBranchRestoreBool == True:
# checkout to the source branch which was
self.BranchCheckout(inBranchNameStr=lBranchNameCurrentStr)
def BranchRevCheck(self, inBranchRemoteStr):
pass
"""Check if branch is last. If not last -> do some actions to get last
def BranchNameGet(self):
:param inBranchRemoteStr: [description]
:type inBranchRemoteStr: [type]
"""
pass
"git rev-parse --abbrev-ref HEAD"
def BranchNameGet(self) -> str:
"""Get the current local branch name
:return: current local branch name
"""
#"git rev-parse --abbrev-ref HEAD"
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git rev-parse --abbrev-ref HEAD"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def BranchCheckout(self, inBranchNameStr):
pass
f"git clean -f -d" # Очистить от лишних файлов
f"git reset --hard" # Откатить файлы, которые отслеживаются Git и которые были изменены
f"git checkout {inBranchNameStr}"
def Clear(self):
"""Clear the all changes in the local folder. Get up to the current revision
"""
# f"git clean -f -d" # Очистить от лишних файлов
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git clean -f -d"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
# f"git reset --hard" # Откатить файлы, которые отслеживаются Git и которые были изменены
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git reset --hard"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
def Fetch(self):
"""
Get updates from the git server.

Loading…
Cancel
Save