Add Nginx configuration Rollback

This commit is contained in:
VirtuBox
2019-08-27 15:12:01 +02:00
parent 5cc1c06e88
commit d24ae7e8d2
7 changed files with 199 additions and 162 deletions

View File

@@ -55,3 +55,28 @@ class WOGit:
return True
else:
return False
def rollback(self, paths, msg="Rolling-Back"):
"""
Rollback last commit to restore previous.
configuration and commit changes automatically
"""
for path in paths:
global git
git = git.bake("--git-dir={0}/.git".format(path),
"--work-tree={0}".format(path))
if os.path.isdir(path):
if not os.path.isdir(path+"/.git"):
Log.error(self, "Unable to find a git repository at {0}"
.format(path))
try:
Log.debug(self, "WOGit: git reset HEAD~ at {0}"
.format(path))
git.reset("HEAD~ --soft")
git.stash("save \"Rollback\"")
except ErrorReturnCode as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to git reset at {0} "
.format(path))
else:
Log.debug(self, "WOGit: Path {0} not present".format(path))