File tree 7 files changed +44
-92
lines changed
7 files changed +44
-92
lines changed Original file line number Diff line number Diff line change
1
+ require 'overcommit/hook/shared/submodule_status'
2
+
1
3
module Overcommit ::Hook ::PostCheckout
2
4
# Checks the status of submodules in the current repository and
3
5
# notifies the user if any are uninitialized, out of date with
4
6
# the current index, or contain merge conflicts.
5
7
class SubmoduleStatus < Base
6
- def run
7
- messages = [ ]
8
- submodule_statuses . each do |submodule_status |
9
- path = submodule_status . path
10
- if submodule_status . uninitialized?
11
- messages << "Submodule #{ path } is uninitialized."
12
- elsif submodule_status . outdated?
13
- messages << "Submodule #{ path } is out of date with the current index."
14
- elsif submodule_status . merge_conflict?
15
- messages << "Submodule #{ path } has merge conflicts."
16
- end
17
- end
18
-
19
- return :pass if messages . empty?
20
-
21
- [ :warn , messages . join ( "\n " ) ]
22
- end
23
-
24
- private
25
-
26
- def submodule_statuses
27
- Overcommit ::GitRepo . submodule_statuses ( recursive : config [ 'recursive' ] )
28
- end
8
+ include Overcommit ::Hook ::Shared ::SubmoduleStatus
29
9
end
30
10
end
Original file line number Diff line number Diff line change
1
+ require 'overcommit/hook/shared/submodule_status'
2
+
1
3
module Overcommit ::Hook ::PostCommit
2
4
# Checks the status of submodules in the current repository and
3
5
# notifies the user if any are uninitialized, out of date with
4
6
# the current index, or contain merge conflicts.
5
7
class SubmoduleStatus < Base
6
- def run
7
- messages = [ ]
8
- submodule_statuses . each do |submodule_status |
9
- path = submodule_status . path
10
- if submodule_status . uninitialized?
11
- messages << "Submodule #{ path } is uninitialized."
12
- elsif submodule_status . outdated?
13
- messages << "Submodule #{ path } is out of date with the current index."
14
- elsif submodule_status . merge_conflict?
15
- messages << "Submodule #{ path } has merge conflicts."
16
- end
17
- end
18
-
19
- return :pass if messages . empty?
20
-
21
- [ :warn , messages . join ( "\n " ) ]
22
- end
23
-
24
- private
25
-
26
- def submodule_statuses
27
- Overcommit ::GitRepo . submodule_statuses ( recursive : config [ 'recursive' ] )
28
- end
8
+ include Overcommit ::Hook ::Shared ::SubmoduleStatus
29
9
end
30
10
end
Original file line number Diff line number Diff line change
1
+ require 'overcommit/hook/shared/submodule_status'
2
+
1
3
module Overcommit ::Hook ::PostMerge
2
4
# Checks the status of submodules in the current repository and
3
5
# notifies the user if any are uninitialized, out of date with
4
6
# the current index, or contain merge conflicts.
5
7
class SubmoduleStatus < Base
6
- def run
7
- messages = [ ]
8
- submodule_statuses . each do |submodule_status |
9
- path = submodule_status . path
10
- if submodule_status . uninitialized?
11
- messages << "Submodule #{ path } is uninitialized."
12
- elsif submodule_status . outdated?
13
- messages << "Submodule #{ path } is out of date with the current index."
14
- elsif submodule_status . merge_conflict?
15
- messages << "Submodule #{ path } has merge conflicts."
16
- end
17
- end
18
-
19
- return :pass if messages . empty?
20
-
21
- [ :warn , messages . join ( "\n " ) ]
22
- end
23
-
24
- private
25
-
26
- def submodule_statuses
27
- Overcommit ::GitRepo . submodule_statuses ( recursive : config [ 'recursive' ] )
28
- end
8
+ include Overcommit ::Hook ::Shared ::SubmoduleStatus
29
9
end
30
10
end
Original file line number Diff line number Diff line change
1
+ require 'overcommit/hook/shared/submodule_status'
2
+
1
3
module Overcommit ::Hook ::PostRewrite
2
4
# Checks the status of submodules in the current repository and
3
5
# notifies the user if any are uninitialized, out of date with
4
6
# the current index, or contain merge conflicts.
5
7
class SubmoduleStatus < Base
6
- def run
7
- messages = [ ]
8
- submodule_statuses . each do |submodule_status |
9
- path = submodule_status . path
10
- if submodule_status . uninitialized?
11
- messages << "Submodule #{ path } is uninitialized."
12
- elsif submodule_status . outdated?
13
- messages << "Submodule #{ path } is out of date with the current index."
14
- elsif submodule_status . merge_conflict?
15
- messages << "Submodule #{ path } has merge conflicts."
16
- end
17
- end
18
-
19
- return :pass if messages . empty?
20
-
21
- [ :warn , messages . join ( "\n " ) ]
22
- end
23
-
24
- private
25
-
26
- def submodule_statuses
27
- Overcommit ::GitRepo . submodule_statuses ( recursive : config [ 'recursive' ] )
28
- end
8
+ include Overcommit ::Hook ::Shared ::SubmoduleStatus
29
9
end
30
10
end
Original file line number Diff line number Diff line change
1
+ module Overcommit ::Hook ::Shared
2
+ # Shared code used by all `SubmoduleStatus` hooks to notify the user if any
3
+ # submodules are uninitialized, out of date with the current index, or contain
4
+ # merge conflicts.
5
+ module SubmoduleStatus
6
+ def run
7
+ messages = [ ]
8
+ submodule_statuses . each do |submodule_status |
9
+ path = submodule_status . path
10
+ if submodule_status . uninitialized?
11
+ messages << "Submodule #{ path } is uninitialized."
12
+ elsif submodule_status . outdated?
13
+ messages << "Submodule #{ path } is out of date with the current index."
14
+ elsif submodule_status . merge_conflict?
15
+ messages << "Submodule #{ path } has merge conflicts."
16
+ end
17
+ end
18
+
19
+ return :pass if messages . empty?
20
+
21
+ [ :warn , messages . join ( "\n " ) ]
22
+ end
23
+
24
+ private
25
+
26
+ def submodule_statuses
27
+ Overcommit ::GitRepo . submodule_statuses ( recursive : config [ 'recursive' ] )
28
+ end
29
+ end
30
+ end
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ def camel_case(str)
91
91
def supported_hook_types
92
92
Dir [ File . join ( HOOK_DIRECTORY , '*' ) ] .
93
93
select { |file | File . directory? ( file ) } .
94
+ reject { |file | File . basename ( file ) == 'shared' } .
94
95
map { |file | File . basename ( file ) . gsub ( '_' , '-' ) }
95
96
end
96
97
Original file line number Diff line number Diff line change 7
7
8
8
hook_types = Dir [ File . join ( Overcommit ::HOOK_DIRECTORY , '*' ) ] .
9
9
select { |f | File . directory? ( f ) } .
10
+ reject { |f | File . basename ( f ) == 'shared' } .
10
11
sort
11
12
12
13
hook_types . each do |hook_type |
You can’t perform that action at this time.
0 commit comments