Slide 1

Slide 1 text

Branch in Time A story about revision histories @tekin

Slide 2

Slide 2 text

Docs-R-Us Seema

Slide 3

Slide 3 text

Seema Docs-R-Us

Slide 4

Slide 4 text

class PatientsController < ApplicationController before_action :load_doctor def index @patients = sorted_patients end def show @patient = @doctor.patients.find(params[:id]) end private def sorted_patients @doctor.patients.sort { |patient| patient.name } end def load_doctor @doctor = doctor_from_current_session

Slide 5

Slide 5 text

class PatientsController < ApplicationController before_action :load_doctor def index @patients = sorted_patients end def show @patient = @doctor.patients.find(params[:id]) end private def sorted_patients @doctor.patients.sort { |patient| patient.name } end def load_doctor @doctor = doctor_from_current_session

Slide 6

Slide 6 text

class PatientsController < ApplicationController before_action :load_doctor def index @patients = sorted_patients end def show @patient = @doctor.patients.find(params[:id]) end private def sorted_patients @doctor.patients.order(:name) end def load_doctor @doctor = doctor_from_current_session

Slide 7

Slide 7 text

class PatientsController < ApplicationController before_action :load_doctor def index @patients = sorted_patients end def show @patient = @doctor.patients.find(params[:id]) end private def sorted_patients @doctor.patients.order(:name) end def load_doctor @doctor = doctor_from_current_session $ rake Run options: --seed 45260 # Running: .................................................................... .................................................................... .................................................................... .................................... Finished in 123.299088s, 23.8629 runs/s, 34.6397 assertions/s. 3311 runs, 45124 assertions, 0 failures, 0 errors, 0 skips

Slide 8

Slide 8 text

class Patient < ApplicationRecord has_many :appointments validates_presence_of :name, :address, :date_of_birth end class Doctor < ApplicationRecord has_many :appointments has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end

Slide 9

Slide 9 text

Git Fu 1. git blame

Slide 10

Slide 10 text

$ git blame app/controllers/patients_controller.rb Git Fu: git blame

Slide 11

Slide 11 text

3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 1) # Controller for listing a doctor's pa 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 2) class PatientsController < Application 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 3) before_filter :load_doctor 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 4) 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 5) def index 6047246d (Josie P 2010-10-29 09:32:25 +0100 6) @patients = sorted_patients 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 7) end 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 8) 9598514f (Josie P 2010-06-28 17:03:21 +0100 9) def show 9598514f (Josie P 2010-06-28 17:03:21 +0100 10) @patient = @doctor.patients.find(p 9598514f (Josie P 2010-06-28 17:03:21 +0100 11) end 9598514f (Richard E 2010-06-28 17:03:21 +0100 12) 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 13) private dbdd0fb9 (Josie P 2010-10-29 09:31:52 +0100 18) 6047246d (Josie P 2010-10-29 09:32:25 +0100 19) def sorted_patients dbdd0fb9 (Josie P 2010-10-29 09:31:52 +0100 20) @doctor.patients.sort {|patient| p dbdd0f69 (Josie P 2010-10-29 09:31:52 +0100 21) end 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 14) $ git blame app/controllers/patients_controller.rb Git Fu: git blame

Slide 12

Slide 12 text

--patch Git Fu: git blame $ git log dbdd0fb9

Slide 13

Slide 13 text

$ git log dbdd0fb9 --patch commit dbdd0fb9e870b91e6925903553f07df3becc9414 Author: Josie Pickford Date: Fri Oct 29 09:31:52 2010 +0100 PR Feedback: Fixed a typo diff --git a/app/controllers/patients_controller.rb b/app/controllers/patients_controller index d7c6df5..1e3debb 100644 --- a/app/controllers/patients_controller.rb +++ b/app/controllers/patients_controller.rb @@ -13,7 +13,7 @@ class PatientsController < ApplicationController private def sorted_patients - @doctor.patients.sort {|pateint| pateint.name } + @doctor.patients.sort {|patient| patient.name } end Git Fu: git blame

Slide 14

Slide 14 text

Git Fu 1. git blame 2. git log -S (AKA The Pickaxe)

Slide 15

Slide 15 text

Git Fu: git log -S (AKA The Pickaxe) $ git log -S "sorted_patients" --patch --reverse

Slide 16

Slide 16 text

Git Fu: git log -S (AKA The Pickaxe) $ git log -S "sorted_patients" --patch --reverse commit 23b6e0c6a9a7a392c312d4f0c51153e0769ebffc Author: Josie Pickford Date: Thurs Oct 28 17:55:32 2010 +0100 Rename method diff --git a/app/controllers/patients_controller.rb b/app/controllers/ patients_controller.rb index 51fbd8a..d7c6df5 100644 --- a/app/controllers/patients_controller.rb +++ b/app/controllers/patients_controller.rb @@ -3,7 +3,7 @@ class PatientsController < ApplicationController before_filter :load_doctor def index - @patients = load_patients + @patients = sorted_patients end

Slide 17

Slide 17 text

Git Fu 1. git blame 2. git log -S (AKA The Pickaxe) 3. Pickaxe Round 2

Slide 18

Slide 18 text

Git Fu: Pickaxe Round 2 $ git log -S "load_patients" --patch --reverse commit 66f95816017b1c6582034d074333fa18884ad3c3 Author: Josie Pickford Date: Thurs Oct 28 17:00:43 2010 +0100 Fix patient ordering bug diff --git a/app/controllers/patients_controller.rb b/app/controllers/patients_controller index cb0e69c..51fbd8a 100644 --- a/app/controllers/patients_controller.rb +++ b/app/controllers/patients_controller.rb @@ -3,7 +3,7 @@ class PatientsController < ApplicationController before_filter :load_doctor def index - @patients = @doctor.patients.order(:name) + @patients = load_patients end

Slide 19

Slide 19 text

Git Fu 1. git blame 2. git log -S (AKA The Pickaxe) 3. Pickaxe Round 2 4. Find the Pull Request

Slide 20

Slide 20 text

Git Fu: Find the Pull Request

Slide 21

Slide 21 text

Git Fu: Find the Pull Request

Slide 22

Slide 22 text

Git Fu: Find the Pull Request

Slide 23

Slide 23 text

Git Fu: Find the Pull Request

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

8 years ago...

Slide 26

Slide 26 text

Docs-R-Us Josie 8 years ago...

Slide 27

Slide 27 text

Doh! ☕ 8 years ago... Josie

Slide 28

Slide 28 text

Y U NO ALPHABETICAL!?

Slide 29

Slide 29 text

class PatientsController < ApplicationController before_filter :load_doctor def index @patients = @doctor.patients.order(:name) end def show @patient = @doctor.patients.find(params[:id]) end private def load_doctor @doctor = doctor_from_current_session end end

Slide 30

Slide 30 text

class PatientsController < ApplicationController before_filter :load_doctor def index @patients = @doctor.patients.order(:name) end def show @patient = @doctor.patients.find(params[:id]) end private def load_doctor @doctor = doctor_from_current_session end end

Slide 31

Slide 31 text

class Doctor < ApplicationRecord has_many :appointments, order: :appointment_date has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end

Slide 32

Slide 32 text

class Doctor < ApplicationRecord has_many :appointments, order: :appointment_date has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end

Slide 33

Slide 33 text

class Doctor < ApplicationRecord has_many :appointments, order: :appointment_date has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end doctor.patients.order(:name) Patients Load (1.0ms) SELECT "patients".* FROM "patients" INNER JOIN "appointments" ON "patients"."id" = "appointments"."patient_id" WHERE “appointments"."doctor_id" = $1 ORDER BY “appointments"."appointment_date" ASC, "patients"."name" ASC irb(main):003:0>

Slide 34

Slide 34 text

class Doctor < ApplicationRecord has_many :appointments has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end , order: :appointment_date

Slide 35

Slide 35 text

class Doctor < ApplicationRecord has_many :appointments has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end $ rake Run options: --seed 45260 # Running: .....F..........FFFF.........F..........FF..............FFFFFFFFF... ..............FFFFFFFFFFFFFFFFFF............................FFFF Finished in 1.273019s, 24.3516 runs/s, 35.3490 assertions/s.

Slide 36

Slide 36 text

class PatientsController < ApplicationController before_filter :load_doctor def index @patients = @doctor.patients.order(:name) end def show @patient = @doctor.patients.find(params[:id]) end private def load_doctor @doctor = doctor_from_current_session end end

Slide 37

Slide 37 text

class PatientsController < ApplicationController before_filter :load_doctor def index @patients = end def show @patient = @doctor.patients.find(params[:id]) end private def load_patients @doctor.patients.sort { |pateint| pateint.name } end def load_doctor @doctor = doctor_from_current_session load_patients

Slide 38

Slide 38 text

Branch history

Slide 39

Slide 39 text

Pull Request (YOLO)

Slide 40

Slide 40 text

Build broke...

Slide 41

Slide 41 text

Build broke...

Slide 42

Slide 42 text

Just one more commit...

Slide 43

Slide 43 text

... and another

Slide 44

Slide 44 text

Ship it!

Slide 45

Slide 45 text

Intermission

Slide 46

Slide 46 text

Intermission

Slide 47

Slide 47 text

No reorder( ) in Rails 2.3.8 Intermission

Slide 48

Slide 48 text

8 years ago...

Slide 49

Slide 49 text

Docs-R-Us 8 years ago... Josie

Slide 50

Slide 50 text

Damn fine coffee! 8 years ago... ☕ Josie

Slide 51

Slide 51 text

Y U NO ALPHABETICAL!?

Slide 52

Slide 52 text

Branch history

Slide 53

Slide 53 text

Branch history

Slide 54

Slide 54 text

Branch history

Slide 55

Slide 55 text

Git Fu 1. git rebase --interactive

Slide 56

Slide 56 text

git rebase --interactive head~3 Git Fu: git rebase --interactive $

Slide 57

Slide 57 text

git rebase --interactive head~3 Git Fu: git rebase --interactive $

Slide 58

Slide 58 text

git rebase --interactive head~3 Git Fu: git rebase --interactive $

Slide 59

Slide 59 text

Git Fu: git rebase --interactive git rebase --interactive head~3 $

Slide 60

Slide 60 text

Pull Request

Slide 61

Slide 61 text

Build broke...

Slide 62

Slide 62 text

Fix the build git add test/integration $ $ [fix-patient-order-bug ee74d2f] Fix patient ordering bug Date: Fri Oct 29 09:36:08 2010 +0100 3 files changed, 44 insertions(+), 3 deletion(-) $ git commit --amend --no-edit

Slide 63

Slide 63 text

Fix the build git push --force-with-lease git add test/integration $ $ [fix-patient-order-bug ee74d2f] Fix patient ordering bug Date: Fri Oct 29 09:36:08 2010 +0100 3 files changed, 44 insertions(+), 3 deletion(-) $ git commit --amend --no-edit

Slide 64

Slide 64 text

Ship it!

Slide 65

Slide 65 text

Back to the future...

Slide 66

Slide 66 text

Docs-R-Us Seema Seema

Slide 67

Slide 67 text

class PatientsController < ApplicationController before_action :load_doctor def index @patients = sorted_patients end def show @patient = @doctor.patients.find(params[:id]) end private def sorted_patients @doctor.patients.sort { |patient| patient.name } end def load_doctor @doctor = doctor_from_current_session

Slide 68

Slide 68 text

3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 1) # Controller for listing a doctor's pa 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 2) class PatientsController < Application 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 3) before_filter :load_doctor 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 4) 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 5) def index 6047246d (Josie P 2010-10-29 09:32:25 +0100 6) @patients = sorted_patients 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 7) end 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 8) 9598514f (Josie P 2010-06-28 17:03:21 +0100 9) def show 9598514f (Josie P 2010-06-28 17:03:21 +0100 10) @patient = @doctor.patients.find(p 9598514f (Josie P 2010-06-28 17:03:21 +0100 11) end 9598514f (Richard E 2010-06-28 17:03:21 +0100 12) 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 13) private dbdd0fb9 (Josie P 2010-10-29 09:31:52 +0100 18) 6047246d (Josie P 2010-10-29 09:32:25 +0100 19) def sorted_patients 33ec144e (Josie P 2010-10-29 09:31:52 +0100 20) @doctor.patients.sort {|patient| p dbdd0f69 (Josie P 2010-10-29 09:31:52 +0100 21) end 3fc122c2 (Richard E 2010-06-28 17:02:54 +0100 14) $ git blame app/controllers/patients_controller.rb Git Fu: git blame

Slide 69

Slide 69 text

$ git log 33ec144e --patch commit 33ec144e70b91e6925903553f07df3becc9414 Author: Josie Pickford Date: Friday Oct 29 09:44:49 2010 +0100 Fix patient ordering bug The patients association is returning patients in appointment date order, even when called with an explicit `order(:name)` scope. This is because the patients association is a has_many :through the appointments association, which has a default order by appointment_date. This causes any queries on the association to always sort first by appointment date: ORDER BY “appointments"."appointment_date" ASC, "patients"."name" ASC) Removing the default ordering from the appointments association is going to take a bit of unpicking. To get the bug resolved in the meantime we can re-sort the patient records after they've been loaded. Separate work has been planned to remove the default ordering altogether. Git Fu: git blame

Slide 70

Slide 70 text

class Doctor < ApplicationRecord has_many :appointments has_many :patients, through: :appointments belongs_to :practice validates_presence_of :name, :practice end

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

• Naming things • Automated tests • Abstractions • Refactoring

Slide 73

Slide 73 text

Your software is more than the code

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Programming as Theory Building Peter Naur

Slide 76

Slide 76 text

Revision History as Theory Capturing

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

Git Fu 1. Configure an environment for good commit messages

Slide 81

Slide 81 text

Configure an environment for good commit messages $ git commit -m "Did a thing"

Slide 82

Slide 82 text

Configure an environment for good commit messages $ git config --global core.editor “subl -w”

Slide 83

Slide 83 text

Configure an environment for good commit messages $ git config --global commit.verbose true

Slide 84

Slide 84 text

Git Fu 1. Configure an environment for good commit messages 2. Capture the why, not the what

Slide 85

Slide 85 text

Capture the why, not the what

Slide 86

Slide 86 text

Git Fu 1. Configure an environment for good commit messages 2. Capture the why, not the what 3. Shape each commit

Slide 87

Slide 87 text

Shape each commit • Create small atomic commits • Shape as you go, not at the end • $ git add --patch / -p

Slide 88

Slide 88 text

Shape each commit dd3b43c Refactor Foo 44b4bd8 Add Bar to Foo

Slide 89

Slide 89 text

Git Fu 1. Configure an environment for good commit messages 2. Capture the why, not the what 4. Treat (local) commits as mutable 3. Shape each commit

Slide 90

Slide 90 text

Treat (local) commits as mutable • $ git commit --amend • $ git rebase --interactive • $ git rebase --abort • --fixup / --autosquash

Slide 91

Slide 91 text

Git Fu 1. Configure an environment for good commit messages 2. Capture the why, not the what 5. Build your instincts; search your histories 4. Treat (local) commits as mutable 3. Shape each commit

Slide 92

Slide 92 text

Build your instincts; search your histories • $ git blame file.rb • $ git log -S "some_code" • $ git annotate file.rb

Slide 93

Slide 93 text

Git Fu 1. Configure an environment for good commit messages 2. Capture the why, not the what 5. Treat (local) commits as mutable 4. Build your instincts; search your histories 3. Shape each commit

Slide 94

Slide 94 text

tekin.co.uk

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

Thanks for the Git Fu @dgheath21 @angelajtodd @grahamashton

Slide 98

Slide 98 text

Help each other Git Better

Slide 99

Slide 99 text

Seema Memoji Josie Memoji Created by Inspiration for the story-based approach Talk Feedback and Advice Slide Advisor Git Fu Indent Hospital Icon Winding Road Photo Sound Effects TEKIN SULEYMAN TEKIN SULEYMAN TEKIN SULEYMAN NADIA ODUNAYO ANDY CROLL ANGELA TODD GRAHAM ASHTON MURRAY STEELE NADIA ODUNAYO KATRINA OWEN BRUCE LEE, ENTER THE DRAGON (1972) FLATICON.COM JESSE BOWSER ON UNSPLASH LEGEND OF ZELDA, A LINK TO THE PAST Cast

Slide 100

Slide 100 text

Branch in Time A story about revision histories @tekin