def branch_from_ref(ref)
      return nil if !ref

      ref = ref.split('/')
      return nil if ref.size != 3 || ref[0..1] != ['refs', 'heads']

      ref.last
    end
def branch_from_ref(ref)
      return nil if !ref

      ref = ref.split('/')
      return nil if ref.size != 3 || ref[0..1] != ['refs', 'heads']

      ref.last
    end
Converts a git ref name to a branch. This is an utility function for webhook formats that only provide the ref
 updated in their information. Returns nil if the passed parameter is not a valid ref.
 The expected format is 'refs/heads/#{branch_name}'. Anything else will be rejected.