Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/git: use exact format for last_revision_* #3912

Merged
merged 1 commit into from
Mar 12, 2018

Conversation

stek29
Copy link
Contributor

@stek29 stek29 commented Mar 12, 2018

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. -- covered by existing tests
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Format for oneline can be overridden in user's gitconfig. If that's the
case, last_revision_commit_of_file won't work properly, and because of
that last_revision_of_file won't work at all.

Here's what I was getting when running brew tests
Failures:

  1) Git#last_revision_commit_of_file gives revision commit based on before_commit when it is not nil
     Failure/Error:
       expect(
         described_class.last_revision_commit_of_file(HOMEBREW_CACHE,
                                                     file,
                                                     before_commit: hash2),
       ).to eq(hash2)

       expected: "ae7a2b6"
            got: "\e[33mae7a2b6cdef0\e[m"

       (compared using ==)
     # ./test/utils/git_spec.rb:34:in `block (3 levels) in <top (required)>'
     # ./test/spec_helper.rb:106:in `block (2 levels) in <top (required)>'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:115:in `block in run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `loop'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:33:in `block (2 levels) in setup'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block (2 levels) in <top (required)>'

  2) Git#last_revision_commit_of_file gives last revision commit when before_commit is nil
     Failure/Error:
       expect(
         described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file),
       ).to eq(hash1)

       expected: "6bec2de"
            got: "\e[33m6bec2dee633f\e[m"

       (compared using ==)
     # ./test/utils/git_spec.rb:28:in `block (3 levels) in <top (required)>'
     # ./test/spec_helper.rb:106:in `block (2 levels) in <top (required)>'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:115:in `block in run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `loop'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:33:in `block (2 levels) in setup'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block (2 levels) in <top (required)>'

  3) Git#last_revision_of_file returns last revision of file
     Failure/Error:
       expect(
         described_class.last_revision_of_file(HOMEBREW_CACHE,
                                               HOMEBREW_CACHE/file),
       ).to eq("blah")

       expected: "blah"
            got: ""

       (compared using ==)
     # ./test/utils/git_spec.rb:44:in `block (3 levels) in <top (required)>'
     # ./test/spec_helper.rb:106:in `block (2 levels) in <top (required)>'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:115:in `block in run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `loop'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:104:in `run'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.5.6/lib/rspec/retry.rb:33:in `block (2 levels) in setup'
     # ./vendor/bundle/ruby/2.3.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block (2 levels) in <top (required)>'

Finished in 1.35 seconds (files took 1.69 seconds to load)
17 examples, 3 failures, 1 pending

Failed examples:

rspec ./test/utils/git_spec.rb:33 # Git#last_revision_commit_of_file gives revision commit based on before_commit when it is not nil
rspec ./test/utils/git_spec.rb:27 # Git#last_revision_commit_of_file gives last revision commit when before_commit is nil
rspec ./test/utils/git_spec.rb:43 # Git#last_revision_of_file returns last revision of file

I have abbrev length set to 12, and oneline formatting is more colorful.

So, instead of relying on overrideable format, it should rather specify
"--format=%h" to get only hash, and speciy --abbrev=7 to force abbrev
length to be 7

After this commit all tests are passing.

Format for oneline can be overridden in user's gitconfig. If that's the
case, last_revision_commit_of_file won't work properly, and because of
that last_revision_of_file won't work at all.

Here's what I was getting when running brew tests:

       expected: "6bec2de"
            got: "\e[33m6bec2dee633f\e[m"

I have abbrev length set to 12, and oneline formatting is more colorful.

So, instead of relying on overrideable format, it should rather specify
"--format=%h" to get only hash, and speciy --abbrev=7 to force abbrev
length to be 7

After this commit tests are passing for me.
@stek29
Copy link
Contributor Author

stek29 commented Mar 12, 2018

==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.0g_1.sierra.bottle.tar.gz
curl: (6) Could not resolve host: homebrew.bintray.com
Error: Failed to download resource "openssl@1.1"

I guess I'd edit commit message a bit to trigger re-buid.

@MikeMcQuaid MikeMcQuaid merged commit 144356e into Homebrew:master Mar 12, 2018
@MikeMcQuaid
Copy link
Member

Thanks so much for your first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @stek29!

@stek29 stek29 deleted the git-log-format branch March 12, 2018 12:09
@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants