Merge lp:~mariusko/charms/precise/node-app/lp1130092_update_support_for_user_application into lp:charms/node-app

Proposed by Marius B. Kotsbak
Status: Merged
Merged at revision: 32
Proposed branch: lp:~mariusko/charms/precise/node-app/lp1130092_update_support_for_user_application
Merge into: lp:charms/node-app
Diff against target: 47 lines (+31/-1)
2 files modified
config.yaml (+1/-1)
hooks/config-changed (+30/-0)
To merge this branch: bzr merge lp:~mariusko/charms/precise/node-app/lp1130092_update_support_for_user_application
Reviewer Review Type Date Requested Status
Mark Mims Pending
Review via email:
To post a comment you must log in.
33. By Marius B. Kotsbak

Fetch with parameter branch/commit is wrong. Change to pull to ensure local branch is merged with the remote.

34. By Marius B. Kotsbak

Fixed the branch detection logic as there are asterix/space in front of the active branch.

35. By Marius B. Kotsbak

Ensure switch to the local branch before "git pull" so that the merge part will be right.

36. By Marius B. Kotsbak

Run "npm install" agin after update in case new nodejs dependencies are introduced.

Also fix the file owners again.

37. By Marius B. Kotsbak

Improve algorithm for updating from git. It was not working properly for commit IDs and new remote branches.

Revision history for this message
Mark Mims (mark-mims) wrote :

whoohoo! so happy to see this

Revision history for this message
Marius B. Kotsbak (mariusko) wrote :

:) If you don't want to experience bzr's rough edges wrt merges (add/add conflict, which Git would handle OK), I suggest reviewing/merging my trunk branch instead, which contains all merged together.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2012-01-28 01:11:44 +0000
3+++ config.yaml 2013-02-28 09:12:22 +0000
4@@ -18,7 +18,7 @@
5 app_branch:
6 type: string
7 default: master
8- description: Application repository deployment branch
9+ description: Application repository deployment branch. Might also be a revision ID (e.g. tag or SHA1 for git) to upgrade/downgrade application.
10 install_root:
11 type: string
12 default: /opt
14=== added file 'hooks/config-changed'
15--- hooks/config-changed 1970-01-01 00:00:00 +0000
16+++ hooks/config-changed 2013-02-28 09:12:22 +0000
17@@ -0,0 +1,30 @@
20+set -eu # -x for verbose logging to juju debug-log
22+umask 002
24+install_root=`config-get install_root`
25+app_name=`config-get app_name`
27+app_branch=`config-get app_branch`
29+cd $app_dir
31+# Always fetch latest if branch requested
32+if git checkout origin/${app_branch}; then # is a local branch
33+ git fetch origin && git checkout origin/${app_branch}
34+else # tag/commit ref?
35+ if ! git checkout ${app_branch}; then # commit does not exist locally
36+ git fetch origin
37+ if ! git checkout origin/${app_branch}; then # not a new remote branch, is a commit ref/tag
38+ git checkout $app_branch
39+ fi
40+ fi
43+npm update && npm install
45+chown -Rf ${app_user}.${app_user} ${app_dir}
47+service ${app_name} restart


People subscribed via source and target branches