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

Fix fatal git failures in tests #832

Merged
merged 1 commit into from
Mar 31, 2017
Merged

Fix fatal git failures in tests #832

merged 1 commit into from
Mar 31, 2017

Conversation

mike-burns
Copy link
Contributor

The tests had started printing git error messages:

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.

These were coming from three places:

  • suspenders.gemspec, which collects all Gem::Specification#files=
    by shelling out to git ls-files.

  • suspenders.gemspec, which collects all
    Gem::Specification#test_files= by shelling out to
    git ls-files -- {test,spec,features}/*.

  • Honeybadger, which figures out which revision to tag the error with by
    invoking rev-parse:

    def from_git
      return nil unless File.directory?('.git')
      `git rev-parse HEAD`.strip rescue nil
    end
    

Although I am unsure why these things started to matter now, I found two
changes that improve the situation:

  • In the test suite, make an initial commit after suspender'ing a
    project.
  • When suspender'ing a project, make the git repo last.

@@ -17,6 +17,12 @@ def run_suspenders(arguments = nil)
`
#{suspenders_bin} #{APP_NAME} #{arguments}
`
Dir.chdir(APP_NAME) do
with_env("HOME", tmp_path) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is all over the double quotes.

@@ -17,6 +17,12 @@ def run_suspenders(arguments = nil)
`
#{suspenders_bin} #{APP_NAME} #{arguments}
`
Dir.chdir(APP_NAME) do
with_env("HOME", tmp_path) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -17,6 +17,12 @@ def run_suspenders(arguments = nil)
`
#{suspenders_bin} #{APP_NAME} #{arguments}
`
Dir.chdir(APP_NAME) do
with_env("HOME", tmp_path) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

The tests had started printing git error messages:

```
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
```

These were coming from three places:

- `suspenders.gemspec`, which collects all `Gem::Specification#files=`
  by shelling out to `git ls-files`.
- `suspenders.gemspec`, which collects all
  `Gem::Specification#test_files=` by shelling out to
  `git ls-files -- {test,spec,features}/*`.
- Honeybadger, which figures out which revision to tag the error with by
  invoking `rev-parse`:

      def from_git
        return nil unless File.directory?('.git')
        `git rev-parse HEAD`.strip rescue nil
      end

Although I am unsure why these things started to matter now, I found two
changes that improve the situation:

- In the test suite, make an initial commit after suspender'ing a
  project.
- When suspender'ing a project, make the git repo last.
@mike-burns mike-burns merged commit 718fb7a into master Mar 31, 2017
@mike-burns mike-burns deleted the more-commits branch March 31, 2017 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants