Skip to content

Commit c0eba0f

Browse files
committed
fixes and improvements of custom git links for node
1 parent 5adb779 commit c0eba0f

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

mytonctrl/mytonctrl.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from mytoncore.telemetry import is_host_virtual
4747
from mytonctrl.migrate import run_migrations
4848
from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config, is_hex, GetColorInt, \
49-
pop_user_from_args
49+
pop_user_from_args, pop_arg_from_args
5050

5151
import sys, getopt, os
5252

@@ -280,15 +280,30 @@ def check_git(input_args, default_repo, text, default_branch='master'):
280280
fix_git_config(git_path)
281281
default_author = "ton-blockchain"
282282

283-
# Get author, repo, branch
283+
branch = pop_arg_from_args(input_args, '--branch')
284+
285+
if '--url' in input_args:
286+
git_url = pop_arg_from_args(input_args, '--url')
287+
if branch is None:
288+
if '#' in git_url:
289+
ref_fragment = git_url.rsplit('#', 1)[1]
290+
if not ref_fragment:
291+
raise Exception("--url fragment after # is empty")
292+
branch = ref_fragment
293+
else:
294+
branch = default_branch
295+
if '#' in git_url:
296+
git_url = git_url.split('#', 1)[0]
297+
return None, None, branch, git_url
298+
284299
local_author, local_repo = get_git_author_and_repo(git_path)
285300
local_branch = get_git_branch(git_path)
286301

287302
# Set author, repo, branch
288303
data = GetAuthorRepoBranchFromArgs(input_args)
289304
need_author = data.get("author")
290305
need_repo = data.get("repo")
291-
need_branch = data.get("branch")
306+
need_branch = data.get("branch") or branch
292307

293308
# Check if remote repo is different from default
294309
if ((need_author is None and local_author != default_author) or
@@ -306,7 +321,7 @@ def check_git(input_args, default_repo, text, default_branch='master'):
306321
if need_branch is None:
307322
need_branch = local_branch
308323
check_branch_exists(need_author, need_repo, need_branch)
309-
return need_author, need_repo, need_branch
324+
return need_author, need_repo, need_branch, None
310325
#end define
311326

312327
def check_branch_exists(author, repo, branch):
@@ -323,8 +338,7 @@ def check_branch_exists(author, repo, branch):
323338

324339
def Update(local, args):
325340
repo = "mytonctrl"
326-
author, repo, branch = check_git(args, repo, "update")
327-
341+
author, repo, branch, _ = check_git(args, repo, "update") # todo: implement --url for update
328342
# Run script
329343
update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh')
330344
runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch]
@@ -346,14 +360,7 @@ def Upgrade(local, ton, args: list):
346360
upgrade_btc_teleport(local, ton, reinstall=True, branch=branch, user=user)
347361
return
348362

349-
git_url = None
350-
351-
if '--url' in args and '--branch' in args:
352-
git_url = args[args.index('--url') + 1]
353-
branch = args[args.index('--branch') + 1]
354-
else:
355-
repo = "ton"
356-
author, repo, branch = check_git(args, repo, "upgrade")
363+
author, repo, branch, git_url = check_git(args, default_repo="ton", text="upgrade")
357364

358365
# bugfix if the files are in the wrong place
359366
liteClient = ton.GetSettings("liteClient")

mytonctrl/scripts/upgrade.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,8 @@ do
2727
done
2828

2929
remote_url="https://github.com/${author}/${repo}.git"
30-
if [ -n "$git_url" ]; then
31-
if [[ "$git_url" == *"#"* ]]; then
32-
remote_url="${git_url%%#*}"
33-
ref_from_url="${git_url##*#}"
34-
35-
if [ "$branch" = "master" ]; then
36-
branch="$ref_from_url"
37-
fi
38-
else
39-
remote_url="$git_url"
40-
fi
30+
if [ -n "${git_url}" ]; then
31+
remote_url="${git_url}"
4132
fi
4233

4334
# Цвета

scripts/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ branch="master"
1818
network="mainnet"
1919
ton_node_version="master" # Default version
2020
ton_node_git_url="https://github.com/ton-blockchain/ton.git"
21+
config_overridden=false
2122

2223
show_help_and_exit() {
2324
echo 'Supported arguments:'

0 commit comments

Comments
 (0)