git_repository: define #to_str

Fixes:

    Error: no implicit conversion of GitRepository into String

when doing `brew pr-pull --autosquash`. See [1].

I contemplated implementing only `#to_s`, but we've historically used
these as `Pathname`s, and `Pathname` defines `#to_str`.

[1] https://github.com/Homebrew/homebrew-core/actions/runs/4784638305/jobs/8506369135#step:10:54
This commit is contained in:
Carlo Cabrera 2023-04-24 21:53:05 +08:00
parent 763c41f006
commit 93c3775147
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -109,6 +109,12 @@ class GitRepository
popen_git("log", "-1", "--pretty=%B", commit, "--", safe: safe, err: :out)&.strip
end
sig { returns(String) }
def to_str
pathname.to_str
end
alias to_s to_str
private
sig { params(args: T.untyped, safe: T::Boolean, err: T.nilable(Symbol)).returns(T.nilable(String)) }