File tree 3 files changed +38
-0
lines changed
3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 10
10
require 'overcommit/hook/base'
11
11
require 'overcommit/hook_context/base'
12
12
require 'overcommit/hook_context'
13
+ require 'overcommit/git_config'
13
14
require 'overcommit/git_repo'
14
15
require 'overcommit/hook_signer'
15
16
require 'overcommit/hook_loader/base'
Original file line number Diff line number Diff line change
1
+ module Overcommit
2
+ # Get configuration options from git
3
+ module GitConfig
4
+ module_function
5
+
6
+ def comment_character
7
+ char = `git config --get core.commentchar` . chomp
8
+ char = '#' if char == ''
9
+ char
10
+ end
11
+ end
12
+ end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe Overcommit ::GitConfig do
4
+ describe '.comment_character' do
5
+ subject { described_class . comment_character }
6
+
7
+ context 'with no configuration' do
8
+ it 'should be "#"' do
9
+ repo do
10
+ `git config --local core.commentchar ''`
11
+ expect ( subject ) . to eq '#'
12
+ end
13
+ end
14
+ end
15
+
16
+ context 'with custom configuration' do
17
+ it 'should be the configured character' do
18
+ repo do
19
+ `git config --local core.commentchar x`
20
+ expect ( subject ) . to eq 'x'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
You can’t perform that action at this time.
0 commit comments