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

gitAndTools.overcommit: init at 0.46.0 #54263

Closed
wants to merge 2 commits into from

Conversation

Gerschtli
Copy link
Contributor

Motivation for this change

Init overcommit at 0.46.0.

Added vendor in .gitignore because this directory gets generated while building gemset.nix.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Gerschtli Gerschtli changed the title gitAndTools.overcommit: init at 0.46.0 [WIP] gitAndTools.overcommit: init at 0.46.0 Jan 18, 2019
@Gerschtli
Copy link
Contributor Author

To use overcommit, it will copy some files (namely template-dir/hooks/*) into the .git/hooks directory of a git repo where you want to install it. The problem is that the gem overcommit is required in these scripts (via require 'overcommit) but can't be found. I have no idea how to fix this. Updating the LOAD_PATH in gemset-config doesn't work..

Does anyone have an idea?

@Gerschtli Gerschtli changed the title [WIP] gitAndTools.overcommit: init at 0.46.0 gitAndTools.overcommit: init at 0.46.0 Jan 20, 2019
@Gerschtli
Copy link
Contributor Author

The problem is that ruby needs to be installed along with overcommit to get this working. How can I tell nix to do so?

@alyssais
Copy link
Member

The problem is that ruby needs to be installed along with overcommit to get this working. How can I tell nix to do so?

The way to fix this is to make the overcommit hook a wrapper that sets the RubyGems environment variables, and then loads the real hook.

Now, doing this is easier said than done, and it’s taken me a whole evening to figure out how to, because I don’t think we’ve ever had a situation like this before, but I have it working now.

Do you mind if I just push a commit to your branch?

.gitignore Outdated Show resolved Hide resolved
@Gerschtli
Copy link
Contributor Author

Oh great, yes feel free to push your changes!

@Gerschtli
Copy link
Contributor Author

Gerschtli commented Feb 18, 2019

It does not work for me..

  1. I checked out the branch.
  2. Executed nix run -f . gitAndTools.overcommit mdl ruby.
  3. Created minimal config:
verify_signatures: false

PreCommit:
  Mdl:
    enabled: true
  1. Executed overcommit --install
  2. Staged a change in a Markdown file.
  3. Then tried to commit, resulting in this:
This repository contains hooks installed by Overcommit, but the `overcommit` gem is not installed.
Install it with `gem install overcommit`.

Furthermore, if I understand your changes correctly, the hooks aren't wrapped:

$> head -n20 .git/hooks/pre-commit
#!/nix/store/k6bmp8wix8f350nwkrmcybx3b7yfbcam-ruby-2.5.3/bin/ruby

# Entrypoint for Overcommit hook integration. Installing Overcommit will result
# in all of your git hooks being copied from this file, allowing the framework
# to manage your hooks for you.

# Prevent a Ruby stack trace from appearing when we interrupt the hook.
# Note that this will be overridden when Overcommit is loaded, since the
# InterruptHandler will redefine the trap at that time.
Signal.trap('INT') do
  puts 'Hook run interrupted'
  exit 130
end

# Allow hooks to be disabled via environment variable so git commands can be run
# in scripts without Overcommit running hooks
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
  exit
end

Gerschtli and others added 2 commits June 12, 2019 00:09
Patches overcommit to use the bundlerApp's GEM_HOME and GEM_PATH. This
means nothing has to be installed globally to use overcommit. A side
effect of this is that, if overcommit is installed globally, hooks will
continue to use the version of overcommit that generated them, and will
have to be regenerated to use a different version of overcommit. This
seems reasonable to me.
@Gerschtli
Copy link
Contributor Author

@alyssais Are you still interested in giving your input? Otherwise I will close this PR because I am unable to fix this.

@alyssais
Copy link
Member

alyssais commented Jun 15, 2019 via email

@Gerschtli
Copy link
Contributor Author

As I'm not able to fix this, I'm closing this PR. If anyone wants to reopen and fix it, feel free to do so.

@Gerschtli Gerschtli closed this Jul 25, 2019
@Gerschtli Gerschtli deleted the add/overcommit branch July 25, 2019 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants