mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
fix: only fetch what is necessary, simplify & improve grepability
This commit is contained in:
parent
66240e1f8d
commit
82173c1d42
28
bench/app.py
28
bench/app.py
@ -228,7 +228,7 @@ def pull_apps(apps=None, bench_path='.', reset=False):
|
||||
rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else ''
|
||||
|
||||
apps = apps or get_apps(bench_path=bench_path)
|
||||
# chech for local changes
|
||||
# check for local changes
|
||||
if not reset:
|
||||
for app in apps:
|
||||
excluded_apps = get_excluded_apps()
|
||||
@ -271,9 +271,10 @@ Here are your choices:
|
||||
reset_cmd = "git reset --hard {remote}/{branch}".format(
|
||||
remote=remote, branch=get_current_branch(app,bench_path=bench_path))
|
||||
if get_config(bench_path).get('shallow_clone'):
|
||||
exec_cmd("git fetch --depth 1 --no-tags", cwd=app_dir)
|
||||
exec_cmd("git fetch --depth=1 --no-tags", cwd=app_dir)
|
||||
exec_cmd(reset_cmd, cwd=app_dir)
|
||||
exec_cmd("git clean -dfx", cwd=app_dir)
|
||||
exec_cmd("git reflog expire --all", cwd=app_dir)
|
||||
exec_cmd("git gc --prune=all", cwd=app_dir)
|
||||
else:
|
||||
exec_cmd("git fetch --all", cwd=app_dir)
|
||||
exec_cmd(reset_cmd, cwd=app_dir)
|
||||
@ -284,20 +285,15 @@ Here are your choices:
|
||||
|
||||
|
||||
def is_version_upgrade(app='frappe', bench_path='.', branch=None):
|
||||
try:
|
||||
fetch_upstream(app, bench_path=bench_path)
|
||||
except CommandFailedError:
|
||||
raise InvalidRemoteException("No remote named upstream for {0}".format(app))
|
||||
|
||||
upstream_version = get_upstream_version(app=app, branch=branch, bench_path=bench_path)
|
||||
|
||||
if not upstream_version:
|
||||
raise InvalidBranchException("Specified branch of app {0} is not in upstream".format(app))
|
||||
raise InvalidBranchException('Specified branch of app {0} is not in upstream remote'.format(app))
|
||||
|
||||
local_version = get_major_version(get_current_version(app, bench_path=bench_path))
|
||||
upstream_version = get_major_version(upstream_version)
|
||||
|
||||
if upstream_version - local_version > 0:
|
||||
if upstream_version > local_version:
|
||||
return (True, local_version, upstream_version)
|
||||
|
||||
return (False, local_version, upstream_version)
|
||||
@ -330,10 +326,6 @@ def use_rq(bench_path):
|
||||
celery_app = os.path.join(bench_path, 'apps', 'frappe', 'frappe', 'celery_app.py')
|
||||
return not os.path.exists(celery_app)
|
||||
|
||||
def fetch_upstream(app, bench_path='.'):
|
||||
repo_dir = get_repo_dir(app, bench_path=bench_path)
|
||||
return subprocess.call(["git", "fetch", "upstream"], cwd=repo_dir)
|
||||
|
||||
def get_current_version(app, bench_path='.'):
|
||||
repo_dir = get_repo_dir(app, bench_path=bench_path)
|
||||
try:
|
||||
@ -352,10 +344,16 @@ def get_develop_version(app, bench_path='.'):
|
||||
|
||||
def get_upstream_version(app, branch=None, bench_path='.'):
|
||||
repo_dir = get_repo_dir(app, bench_path=bench_path)
|
||||
try:
|
||||
subprocess.call('git fetch --depth=1 --no-tags upstream', shell=True, cwd=repo_dir)
|
||||
except CommandFailedError:
|
||||
raise InvalidRemoteException('Failed to fetch from remote named upstream for {0}'.format(app))
|
||||
|
||||
if not branch:
|
||||
branch = get_current_branch(app, bench_path=bench_path)
|
||||
try:
|
||||
contents = subprocess.check_output(['git', 'show', 'upstream/{branch}:{app}/__init__.py'.format(branch=branch, app=app)], cwd=repo_dir, stderr=subprocess.STDOUT)
|
||||
contents = subprocess.check_output('git show upstream/{branch}:{app}/__init__.py'.format(branch=branch, app=app),
|
||||
shell=True, cwd=repo_dir, stderr=subprocess.STDOUT)
|
||||
contents = contents.decode('utf-8')
|
||||
except subprocess.CalledProcessError as e:
|
||||
if b"Invalid object" in e.output:
|
||||
|
Loading…
Reference in New Issue
Block a user