Project

General

Profile

Development cycle » History » Version 9

Tom Clegg, 08/12/2011 09:11 PM

1 1 Tom Clegg
h1. Development cycle
2
3 4 Tom Clegg
h2. Getting the code base
4
5
 git clone git@git.clinicalfuture.com:pgp-enroll.git
6
7 1 Tom Clegg
h2. Writing and contributing code
8
9
Start a branch like username/master or username/rails3
10
11
 git branch example/rails3
12
git checkout example/rails3
13
14
Do something trivial like
15
16
* add app/views/pages/specimen_collection.html.erb
17
* add link to it in app/views/pages/home.html.erb
18
19 3 Tom Clegg
Commit it.  If you refer to the issue# in the comment, redmine will notice this and do smart things (e.g., link to the commit from the issue page).
20 1 Tom Clegg
21
 git add ...
22 3 Tom Clegg
git commit -m 'description of stuff (closes #123)'
23 1 Tom Clegg
24
Push it
25
26
 git push
27
28
Generate a pull request
29
30
 git request-pull e68ab19^ git@git.clinicalfuture.com:pgp-enroll.git e68ab19
31
32
Send the pull request to someone like Ward
33
34 2 Ward Vandewege
h2. Merging code from other contributors/branches
35 1 Tom Clegg
36 4 Tom Clegg
Fetch latest code in other developers branches
37 1 Tom Clegg
38 4 Tom Clegg
 git fetch
39 1 Tom Clegg
40 4 Tom Clegg
List remote branches
41
42
 git branch -a
43
44 1 Tom Clegg
Switch to the other branch
45 2 Ward Vandewege
46 1 Tom Clegg
 git checkout origin/example/rails3
47 2 Ward Vandewege
48
(git will complain about being in a detached head state, but that's fine - just don't commit to this state)
49
50
Now look around, test
51 1 Tom Clegg
52 2 Ward Vandewege
 git log
53
54 4 Tom Clegg
Switch to production branch (set up with @git checkout --track origin/rails3@ if you haven't already) and make sure it's up-to-date
55 2 Ward Vandewege
56
 git checkout rails3
57 4 Tom Clegg
git pull origin rails3
58 2 Ward Vandewege
59 5 Tom Clegg
See what hasn't been merged
60
61
 git cherry -v rails3 origin/example/rails3
62
63 1 Tom Clegg
Cherry-pick a commit
64
65
 git cherry-pick e68ab19
66
67 2 Ward Vandewege
Or merge the entire remote tree (this will fetch and merge but not yet commit)
68
69
 git merge --no-commit origin/tomc/rails3
70
 
71
When you're happy, 
72
73
 git commit
74
75
Or rewind
76
77
 git reset --hard rails3
78
79
Finally, push
80 1 Tom Clegg
81
 git push
82 5 Tom Clegg
83
h2. Deploying to my-dev
84
85 6 Tom Clegg
Basics
86
87
 sudo gem install capistrano
88
89 5 Tom Clegg
Make sure "ssh www-dev.sum" puts you in root@www-dev and includes agent forwarding.
90 1 Tom Clegg
91 6 Tom Clegg
 Host www-dev.sum
92 5 Tom Clegg
  HostName www-dev
93
  User root
94
  ForwardAgent yes
95 1 Tom Clegg
  ExitOnForwardFailure yes
96 6 Tom Clegg
97
Check out production branch
98
99
 git checkout rails3
100
101
Deploy to www-dev
102
103
 cap deploy
104
105
Do db migrations on www-dev
106
107 9 Tom Clegg
 ssh root@www-dev.sum sh -c "'cd /var/www/my-dev.personalgenomes.org/current && RAILS_ENV=staging rake db:migrate'"
108 7 Tom Clegg
109
h2. Deploying to production server
110
111 8 Tom Clegg
Make sure "ssh www-prod.sum" puts you in root@www-prod and includes agent forwarding.
112 7 Tom Clegg
113
 Host www-prod.sum
114
  HostName www-prod
115
  User root
116
  ForwardAgent yes
117
  ExitOnForwardFailure yes
118
119
Check out production branch
120
121
 git checkout rails3
122
123
Deploy to www-prod
124
125
 cap deploy -f Capfile.production
126
127 1 Tom Clegg
Do db migrations on www-prod
128 7 Tom Clegg
129 9 Tom Clegg
 ssh root@www-prod.sum sh -c "'cd /var/www/my.personalgenomes.org/current && RAILS_ENV=production rake db:migrate'"