Today I Learned

Giant Monkeys Learning

Method git history with `git log -L`

Today I found out that - via git log -L - it’s possible to list the history of changes to a specific method:

$ git log -L :initialize:app/lib/giant_money.rb -n5

commit e6ef7f8a3cf06af2ecbf8a528ad5cf312a8d03b1
Author: Alexander Presber <post@momolog.info>
Date:   Sun Aug 13 20:05:59 2023 +0200

    don't fail hard (yet) on GiantMoney[nil] [GOM-8932]

diff --git a/app/lib/giant_money.rb b/app/lib/giant_money.rb
--- a/app/lib/giant_money.rb
+++ b/app/lib/giant_money.rb
@@ -16,12 +16,16 @@
   def initialize value, allow_nil: false
-    raise "GiantMoney.new: value cannot be nil." unless value || allow_nil
+
+    unless value || allow_nil
+      # raise "GiantMoney.new: value cannot be nil." # don't fail hard (yet) on GiantMoney[nil]
+      Rollbar.error("GiantMoney.new: value cannot be nil in #{caller[2]}.", stack: caller)
+    end

     @amount = case value
       when nil      then nil
       when Money    then value
       when Integer  then Money.new(value)
       when Float    then Money.new((value * 100.0))
       else raise 'GiantMoney.new: value needs to be an Integer, Float or Money object.'
     end
   end


commit f55678a8c33029b1e998e1e0b6d536afd2f77107
Author: Lion Vollnhals <lion@giantmonkey.de>
Date:   Fri Jun 9 12:58:05 2023 +0000

    giant_monkey: multiple float by float

diff --git a/app/lib/giant_money.rb b/app/lib/giant_money.rb
--- a/app/lib/giant_money.rb
+++ b/app/lib/giant_money.rb
@@ -16,12 +16,12 @@
   def initialize value, allow_nil: false
...

Noice.