Skip to content

Commit

Permalink
fix: validate branch in bench update
Browse files Browse the repository at this point in the history
bench update assumes that erpnext is an installed app in the bench. This is a wrong assumption. This work around checks for the intersection of installed apps with  the list ['frappe', 'erpnext'] and only attempts to get the current branch of apps that occur in the intersection. This way, if erpnext is not installed (very likely for those using frappe only to build their own apps) there wont be an error when get_current_branch is called for erpnext. The need to perform the kind of check being performed in validate_branch is a strong case for considering apps being able to add "bench update" hooks in their hooks.py

See this topic https://discuss.erpnext.com/t/bench-update-error-no-such-file-or-directory-apps-erpnext/56932?u=chude_osiegbu
  • Loading branch information
ckosiegbu authored and gavindsouza committed Jan 20, 2020
1 parent 5271e1e commit 5762724
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,14 @@ def get_apps_json(path):
return json.load(f)

def validate_branch():
for app in ['frappe', 'erpnext']:
installed_apps = get_apps()
check_apps = ['frappe', 'erpnext'] #this is a dirty work-around. bench update should not assume that erpnext is installed
intersection_apps = list(set(installed_apps) & set(check_apps))
for app in intersection_apps:
branch = get_current_branch(app)

if branch == "master":
print(''' master branch is renamed to version-11 and develop to version-12. Please switch to new branches to get future updates.
To switch to version 11, run the following commands: bench switch-to-branch version-11''')
sys.exit(1)
sys.exit(1)

0 comments on commit 5762724

Please sign in to comment.