2. Who am I???
•
From New Zealand (sorry for the
accent)
•
Live in Hackney
•
Solutions Architect @ Acquia
•
A casual contributor to Drupal core
•
Maintain a few simple modules on
d.o
•
Like to help new contributors as
much as I can
•
cam8001 on drupal.org, IRC, Twitter
7. The cli is your friend
•
Use git on command line. If this scares you, I
can comfort you.
•
If you are on OS X - use brew!
•
If you are on Linux, use your package manager
•
If you are on Windows, try this https://drupal.org/
documentation/git/install
8. First, git clone
•
Gets a complete copy of Drupal and all its
history
██ cameron.tod @ kerbcrawler:~
🍺
██ 13:02:45 $ git clone --branch 8.x http://git.drupal.org/project/drupal.git
Cloning into 'drupal'...
remote: Counting objects: 319961, done.
remote: Compressing objects: 100% (62618/62618), done.
remote: Total 319961 (delta 223601), reused 317995 (delta 222129)
Receiving objects: 100% (319961/319961), 74.74 MiB | 291.00 KiB/s, done.
Resolving deltas: 100% (223601/223601), done.
Checking connectivity... done
██ cameron.tod @ kerbcrawler:~/Sites/drupal (8.x)
🍺
██ 01:13:34 $ git lg 008612ad4999138662a32abab2115cf3f03bca64
* 008612a - Imported sources (14 years ago) <Dries Buytaert>
9. Our workflow
1. Create your issue branch
2. Make your changes
3. Stage your changes
4. Commit your changes
5. Make a patch file
6. Upload it to drupal.org for review
10.
11. Commit
•
A single changeset, relative to a repository and
file system
•
Git stores commits as snapshots
•
Commit metadata; author, timestamp, message
13. So what is a branch?
•
A branch is a stream of commits
•
A branch has full history
•
One repo can have many branches
•
You can branch at any point, or merge branches
back together into a single history
14. Files have 3 states
•
Committed
•
Modified
•
Staged
15.
16.
17. 1. Create your issue branch
Creates a new branch
██ cameron.tod @ kerbcrawler:~/Sites/drupal-pres (8.x)
Branch name prefixed with issue number
🍺
██ 15:47:07 $ git checkout -b 2091511-cache_form_expiry_to_variable
Switched to a new branch '2091511-cache_form_expiry_to_variable'
!
██ cameron.tod @ kerbcrawler:~/Sites/drupal-pres (2091511-cache_form_expiry_to_variable)
🍺
██ 15:47:13 $
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 15:47:54 $ git branch
* 2091511-cache_form_expiry_to_variable
8.x
Brief description of the issue
20. Modified state
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 00:40:39 $ git status
# On branch 2091511-cache_form_expiry_to_variable
#
# Changes not staged for commit:
#
(use "git add <file>..." to update what will be committed)
#
(use "git checkout -- <file>..." to discard changes in working directory)
#
#
modified:
core/lib/Drupal/Core/Form/FormBuilder.php
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 00:42:09 $ git diff core/lib/Drupal/Core/Form/FormBuilder.php
!
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 49692d9..d70bf4f 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -390,8 +390,7 @@ public function getCache($form_build_id, &$form_state) {
* {@inheritdoc}
*/
public function setCache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty.
$expire = 21600;
+
$expire = Drupal::config('system.form')->get('cache_expire');
// Cache form structure.
if (isset($form)) {
21. 3. Stage your changes
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 01:53:46 $ git add core/lib/Drupal/Core/Form/FormBuilder.php
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
██ 01:28:58 $ git status
# On branch 2091511-cache_form_expiry_to_variable
# Your branch is behind 'origin/8.x' by 17 commits, and can be fast-forwarded.
#
(use "git pull" to update your local branch)
#
# Changes to be committed:
#
(use "git reset HEAD <file>..." to unstage)
#
#
modified:
core/lib/Drupal/Core/Form/FormBuilder.php
🍺
22. 4. Commit your changes
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 01:32:38 $ git commit -m 'Added form expiration as a config.'
[2091511-cache_form_expiry_to_variable 7d1ca38] Added form expiration as a config.
1 file changed, 1 insertion(+), 2 deletions(-)
!
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 16:30:09 $ git lg
* 22edfd2 - (HEAD, 2091511-cache_form_expiry_to_variable) Added form expiration as a config. (57 seconds ago) <Cameron Tod>
* 5fb617d - Issue #1938926 by sun, Cottser, joelpittet, pplantinga: Convert simpletest theme tables to table #type. (21 hours ago) <Dries>
23. 5. Make a patch file
•
A patch file is a commit changeset, saved in a
text file
•
When you upload your patch to Drupal:
•
The testbots pick it up, apply the patch to
Drupal core, and test it on qa.drupal.org
•
Other contributors can download it and apply
it to their git repository
24. $ git diff origin/8.x
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 49692d9..d70bf4f 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -390,8 +390,7 @@ public function getCache($form_build_id, &$form_state) {
* {@inheritdoc}
*/
public function setCache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty.
$expire = 21600;
+
$expire = Drupal::config('system.form')->get('cache_expire');
// Cache form structure.
if (isset($form)) {
$ git diff origin/8.x > 2091511-cache_form_expiry_to_variable-27.patch
$ cat 2091511-cache_form_expiry_to_variable-27.patch
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 49692d9..d70bf4f 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -390,8 +390,7 @@ public function getCache($form_build_id, &$form_state) {
* {@inheritdoc}
*/
public function setCache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty.
$expire = 21600;
+
$expire = Drupal::config('system.form')->get('cache_expire');
// Cache form structure.
if (isset($form)) {
25. But don’t forget to rebase
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 22:52:22 $ git fetch
remote: Counting objects: 857, done.
remote: Compressing objects: 100% (234/234), done.
remote: Total 534 (delta 334), reused 324 (delta 199)
Receiving objects: 100% (534/534), 93.66 KiB | 0 bytes/s, done.
Resolving deltas: 100% (334/334), completed with 225 local objects.
From http://git.drupal.org/project/drupal
7d985d5..3ae51ab 8.x
-> origin/8.x
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 22:54:12 $ git rebase origin/8.x
First, rewinding head to replay your work on top of it...
Applying: Added form expiration as a config.
Applying: Adding closing newline to system.form.yml.
Applying: Explicitly set cache expiry for cache_form.
Applying: Moved form_cache expire setting into system_performance.yml.
Applying: Added new config key to tests.
Applying: Added config schema for new config key.
Applying: Changed form cache expire key.
Applying: Added config.factory stub to test.
Applying: Added value to config factory stub.
██ cameron.tod @ kerbcrawler:~/Sites/drupal (2091511-cache_form_expiry_to_variable)
🍺
██ 22:55:49 $ git lg
* b23c13a - (HEAD, 2091511-cache_form_expiry_to_variable) Added value to config factory stub. (57 seconds ago) <Cameron Tod>
* 0c2eec4 - Added config.factory stub to test. (57 seconds ago) <Cameron Tod>
* 4df1959 - Changed form cache expire key. (57 seconds ago) <Cameron Tod>
* e2f18d3 - Added config schema for new config key. (57 seconds ago) <Cameron Tod>
* 0f54db6 - Added new config key to tests. (57 seconds ago) <Cameron Tod>
* cef2510 - Moved form_cache expire setting into system_performance.yml. (57 seconds ago) <Cameron Tod>
* 141ce4e - Explicitly set cache expiry for cache_form. (58 seconds ago) <Cameron Tod>
* 9346d8e - Adding closing newline to system.form.yml. (58 seconds ago) <Cameron Tod>
* 9408e2c - Added form expiration as a config. (58 seconds ago) <Cameron Tod>
* 3ae51ab - (origin/HEAD, origin/8.x) Issue #2201149 by sidharthap, sandipmkhairnar: Remove comment_entity_info cache deletes. (11 hours ago)
<Nathaniel Catchpole>
26. Keep commits small
$ git lg 668d277...
* b23c13a - (HEAD, 2091511-cache_form_expiry_to_variable) Added value to config factory stub. (3 hours ago) <Cameron Tod>
* 0c2eec4 - Added config.factory stub to test. (3 hours ago) <Cameron Tod>
* 4df1959 - Changed form cache expire key. (3 hours ago) <Cameron Tod>
* e2f18d3 - Added config schema for new config key. (3 hours ago) <Cameron Tod>
* 0f54db6 - Added new config key to tests. (3 hours ago) <Cameron Tod>
* cef2510 - Moved form_cache expire setting into system_performance.yml. (3 hours ago) <Cameron Tod>
* 141ce4e - Explicitly set cache expiry for cache_form. (3 hours ago) <Cameron Tod>
* 9346d8e - Adding closing newline to system.form.yml. (3 hours ago) <Cameron Tod>
* 9408e2c - Added form expiration as a config. (3 hours ago) <Cameron Tod>
* 3ae51ab - (origin/HEAD, origin/8.x) Issue #2201149 by sidharthap, sandipmkhairnar: Remove comment_entity_info cache deletes. (14 hours ago)
<Nathaniel Catchpole>
33. Branches are cheap
•
Create ‘em like crazy!
•
They take no time at all!!
•
You can branch from any point!
•
Create one for every issue!
•
Remember, everything is a branch.
And you can branch from a branch.!
•
Switch between branches quickly
and easily!
•
No one else will ever see them.
You can’t break Drupal core with git
34. If you remember one (more)
thing…
•
Everything is a branch
•
Everything is a branch
•
Everything is a branch
•
Every commit? A fully functional branch
•
Every tag? A branch.
•
Your remote upstream server (git.drupal.org)? A branch.
Locally.
•
A branch?? A branch.
35. Use case: test + fix branch
$ git checkout
maintenance-mode-cache-pages-1032936-fixes
Checking out files: 100% (5288/5288), done.
Switched to branch 'maintenance-mode-cache-pages-1032936-fixes'
$ git checkout
maintenance-mode-cache-pages-1032936-tests
Switched to branch 'maintenance-mode-cache-pages-1032936-tests'
$ git checkout -b maintenance-mode-cache-pages-1032936-tests+fixes
Switched to a new branch 'maintenance-mode-cache-pages-1032936-tests+fixes'
$ git merge maintenance-mode-cache-pages-1032936-fixes
Merge made by the 'recursive' strategy.
core/includes/bootstrap.inc | 5 ++++1 file changed, 4 insertions(+), 1 deletion(-)
45. Thank you!
•
Slides will be on http://2014.drupalcamplondon.co.uk/
•
Come to Drupal monthly sprints at Techhub @
Campus, Shoreditch
•
We are hiring! Technical Architects, Devops,
Technical Account Managers, Solutions Architects.
Come and find me if you’re interested :)