-
Notifications
You must be signed in to change notification settings - Fork 184
add support for custom TON node git URL #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,7 +46,7 @@ | |||||||||||||||||||||||
| from mytoncore.telemetry import is_host_virtual | ||||||||||||||||||||||||
| from mytonctrl.migrate import run_migrations | ||||||||||||||||||||||||
| from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config, is_hex, GetColorInt, \ | ||||||||||||||||||||||||
| pop_user_from_args | ||||||||||||||||||||||||
| pop_user_from_args, pop_arg_from_args | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import sys, getopt, os | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -280,15 +280,30 @@ def check_git(input_args, default_repo, text, default_branch='master'): | |||||||||||||||||||||||
| fix_git_config(git_path) | ||||||||||||||||||||||||
| default_author = "ton-blockchain" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Get author, repo, branch | ||||||||||||||||||||||||
| branch = pop_arg_from_args(input_args, '--branch') | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if '--url' in input_args: | ||||||||||||||||||||||||
| git_url = pop_arg_from_args(input_args, '--url') | ||||||||||||||||||||||||
| if branch is None: | ||||||||||||||||||||||||
| if '#' in git_url: | ||||||||||||||||||||||||
| ref_fragment = git_url.rsplit('#', 1)[1] | ||||||||||||||||||||||||
| if not ref_fragment: | ||||||||||||||||||||||||
| raise Exception("--url fragment after # is empty") | ||||||||||||||||||||||||
| branch = ref_fragment | ||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||
| branch = default_branch | ||||||||||||||||||||||||
| if '#' in git_url: | ||||||||||||||||||||||||
| git_url = git_url.split('#', 1)[0] | ||||||||||||||||||||||||
| return None, None, branch, git_url | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| local_author, local_repo = get_git_author_and_repo(git_path) | ||||||||||||||||||||||||
| local_branch = get_git_branch(git_path) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Set author, repo, branch | ||||||||||||||||||||||||
| data = GetAuthorRepoBranchFromArgs(input_args) | ||||||||||||||||||||||||
| need_author = data.get("author") | ||||||||||||||||||||||||
| need_repo = data.get("repo") | ||||||||||||||||||||||||
| need_branch = data.get("branch") | ||||||||||||||||||||||||
| need_branch = data.get("branch") or branch | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Check if remote repo is different from default | ||||||||||||||||||||||||
| 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'): | |||||||||||||||||||||||
| if need_branch is None: | ||||||||||||||||||||||||
| need_branch = local_branch | ||||||||||||||||||||||||
| check_branch_exists(need_author, need_repo, need_branch) | ||||||||||||||||||||||||
| return need_author, need_repo, need_branch | ||||||||||||||||||||||||
| return need_author, need_repo, need_branch, None | ||||||||||||||||||||||||
| #end define | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def check_branch_exists(author, repo, branch): | ||||||||||||||||||||||||
|
|
@@ -323,8 +338,7 @@ def check_branch_exists(author, repo, branch): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def Update(local, args): | ||||||||||||||||||||||||
| repo = "mytonctrl" | ||||||||||||||||||||||||
| author, repo, branch = check_git(args, repo, "update") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| author, repo, branch, _ = check_git(args, repo, "update") # todo: implement --url for update | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yungwine I propose to remove |
||||||||||||||||||||||||
| # Run script | ||||||||||||||||||||||||
| update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh') | ||||||||||||||||||||||||
| runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch] | ||||||||||||||||||||||||
|
Comment on lines
+341
to
344
|
||||||||||||||||||||||||
| author, repo, branch, _ = check_git(args, repo, "update") # todo: implement --url for update | |
| # Run script | |
| update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh') | |
| runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch] | |
| author, repo, branch, git_url = check_git(args, repo, "update") # implemented --url for update | |
| # Run script | |
| update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh') | |
| if git_url is not None: | |
| runArgs = ["bash", update_script_path, "-u", git_url, "-b", branch] | |
| else: | |
| runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,11 @@ if [ "$(id -u)" != "0" ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| while getopts ":c:v:h" flag; do | ||
| repo_git_url="https://github.com/ton-blockchain/ton.git" | ||
|
|
||
| while getopts ":c:v:g:h" flag; do | ||
| case "${flag}" in | ||
| g) repo_git_url=${OPTARG};; | ||
| c) config=${OPTARG};; | ||
| v) ton_node_version=${OPTARG};; | ||
| h) show_help_and_exit;; | ||
|
|
@@ -108,7 +111,7 @@ make build_libs -j$(nproc) | |
| echo -e "${COLOR}[3/6]${ENDC} Preparing for compilation" | ||
| cd $SOURCES_DIR | ||
| rm -rf $SOURCES_DIR/ton | ||
| git clone --recursive https://github.com/ton-blockchain/ton.git | ||
| git clone --recursive $repo_git_url $SOURCES_DIR/ton | ||
|
Comment on lines
113
to
+114
|
||
|
|
||
| echo "checkout to ${ton_node_version}" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fragment parsing doesn't validate the extracted branch name. This could allow injection of arbitrary git references that might not be safe branch/tag names.