Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mytoncore/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import subprocess

from mytoncore.mytoncore import MyTonCore
from mytonctrl.utils import fix_git_config
from mytoninstaller.config import GetConfig
from mypylib.mypylib import (
b2mb,
Expand Down Expand Up @@ -420,7 +421,9 @@ def Telemetry(local, ton):

# Get git hashes
gitHashes = dict()
gitHashes["mytonctrl"] = get_git_hash("/usr/src/mytonctrl")
mtc_path = "/usr/src/mytonctrl"
local.try_function(fix_git_config, args=[mtc_path])
gitHashes["mytonctrl"] = get_git_hash(mtc_path)
gitHashes["validator"] = GetBinGitHash(
"/usr/bin/ton/validator-engine/validator-engine")
data["gitHashes"] = gitHashes
Expand Down
19 changes: 3 additions & 16 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
GetBinGitHash,
)
from mytonctrl.migrate import run_migrations
from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime
from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config

import sys, getopt, os

Expand Down Expand Up @@ -290,21 +290,6 @@ def check_vport(local, ton):
#end define


def fix_git_config(git_path: str):
args = ["git", "status"]
try:
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=git_path, timeout=3)
err = process.stderr.decode("utf-8")
except Exception as e:
err = str(e)
if err:
if 'git config --global --add safe.directory' in err:
args = ["git", "config", "--global", "--add", "safe.directory", git_path]
subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
else:
raise Exception(f'Failed to check git status: {err}')
#end define

def check_git(input_args, default_repo, text):
src_dir = "/usr/src"
git_path = f"{src_dir}/{default_repo}"
Expand Down Expand Up @@ -708,6 +693,8 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid
validatorBinGitPath = "/usr/bin/ton/validator-engine/validator-engine"
mtcGitHash = get_git_hash(mtcGitPath, short=True)
validatorGitHash = GetBinGitHash(validatorBinGitPath, short=True)
fix_git_config(mtcGitPath)
fix_git_config(validatorGitPath)
mtcGitBranch = get_git_branch(mtcGitPath)
validatorGitBranch = get_git_branch(validatorGitPath)
mtcGitHash_text = bcolors.yellow_text(mtcGitHash)
Expand Down
17 changes: 17 additions & 0 deletions mytonctrl/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import time


Expand All @@ -12,3 +13,19 @@ def GetItemFromList(data, index):
return data[index]
except:
pass


def fix_git_config(git_path: str):
args = ["git", "status"]
try:
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=git_path, timeout=3)
err = process.stderr.decode("utf-8")
except Exception as e:
err = str(e)
if err:
if 'git config --global --add safe.directory' in err:
args = ["git", "config", "--global", "--add", "safe.directory", git_path]
subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
else:
raise Exception(f'Failed to check git status: {err}')
#end define