From d4831a6bf7f82b21653c372e15f6d3a418b5d025 Mon Sep 17 00:00:00 2001 From: armink Date: Fri, 28 Feb 2020 18:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=AD=A3=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BB=93=E5=BA=93=E6=97=B6=EF=BC=8C=E5=9C=A8=E4=B8=AA?= =?UTF-8?q?=E5=88=AB=20windows=20git=20autocrlf=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA=20false=20=E7=9A=84=E7=8E=AF=E5=A2=83=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- cmds/cmd_package.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmds/cmd_package.py b/cmds/cmd_package.py index 73435ad3..2689b022 100644 --- a/cmds/cmd_package.py +++ b/cmds/cmd_package.py @@ -72,6 +72,13 @@ def execute_command(cmdstring, cwd=None, shell=True): return stdout_str +def git_pull_repo(repo_path, repo_url=''): + if platform.system() == "Windows": + cmd = r'git config --local core.autocrlf true' + execute_command(cmd, cwd=repo_path) + cmd = r'git pull ' + repo_url + execute_command(cmd, cwd=repo_path) + def determine_support_chinese(env_root): get_flag_file_path = os.path.join(env_root, 'tools', 'bin', 'env_above_ver_1_1') if os.path.isfile(get_flag_file_path): @@ -521,8 +528,7 @@ def update_latest_packages(pkgs_fn, bsp_packages_path): print("Failed to connect to the mirror server, using non-mirror server to update.") # Update the package repository from upstream. - cmd = 'git pull' - git_cmd_exec(cmd, repo_path) + git_pull_repo(repo_path) # If the package has submodules, update the submodules. update_submodule(repo_path) @@ -1045,8 +1051,7 @@ def upgrade_packages_index(): print ("upgrade from :%s" % (git_repo.encode("utf-8"))) else: print("Begin to upgrade env packages.") - cmd = r'git pull ' + git_repo - execute_command(cmd, cwd=pkgs_path) + git_pull_repo(pkgs_path, git_repo) print("==============================> Env packages upgrade done \n") for filename in os.listdir(packages_root): @@ -1058,8 +1063,7 @@ def upgrade_packages_index(): if os.path.isdir(os.path.join(package_path, '.git')): print("Begin to upgrade %s." % filename) - cmd = r'git pull' - execute_command(cmd, cwd=package_path) + git_pull_repo(package_path) print("==============================> Env %s update done \n" % filename) @@ -1081,8 +1085,7 @@ def upgrade_env_script(): env_scripts_repo = 'https://github.com/RT-Thread/env.git' env_scripts_root = os.path.join(env_root, 'tools', 'scripts') - cmd = r'git pull ' + env_scripts_repo - execute_command(cmd, cwd=env_scripts_root) + git_pull_repo(env_scripts_root, env_scripts_repo) print("==============================> Env scripts upgrade done \n")