avm-git 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/git/scms/git/changed_file.rb +16 -0
- data/lib/avm/git/scms/git/changed_files.rb +24 -0
- data/lib/avm/git/scms/git/commit.rb +10 -0
- data/lib/avm/git/scms/git/commits.rb +57 -0
- data/lib/avm/git/scms/git/interval.rb +31 -0
- data/lib/avm/git/scms/git/milestones.rb +21 -0
- data/lib/avm/git/scms/git/run_commit.rb +57 -0
- data/lib/avm/git/scms/git.rb +6 -35
- data/lib/avm/git/scms/git_subrepo.rb +2 -1
- data/lib/avm/git/version.rb +1 -1
- metadata +20 -19
- data/lib/avm/git/auto_commit/commit_info.rb +0 -23
- data/lib/avm/git/auto_commit/rules/base.rb +0 -39
- data/lib/avm/git/auto_commit/rules/last.rb +0 -19
- data/lib/avm/git/auto_commit/rules/manual.rb +0 -45
- data/lib/avm/git/auto_commit/rules/new.rb +0 -24
- data/lib/avm/git/auto_commit/rules/nth.rb +0 -31
- data/lib/avm/git/auto_commit/rules/unique.rb +0 -21
- data/lib/avm/git/auto_commit/rules.rb +0 -31
- data/lib/avm/git/auto_commit_path/ruby.rb +0 -20
- data/lib/avm/git/auto_commit_path.rb +0 -28
- data/lib/avm/git/file_auto_fixup.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dbbeaecd11ef3df5fcdc6467875ee5e4cbd4bbf0ec16878c56ea0b0996b726b
|
4
|
+
data.tar.gz: 257081841d148f3195076725ab146b4f12d47fc143db3b7e6bd7467840a2a481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c40bfcfd621c1dc6137dcece97b85e5158b32419b529ec721aebd7eeb622e8692fbf8229fee08216d148592e6bbc1344043ce7bee2ae8ac06235ad920f7a900
|
7
|
+
data.tar.gz: 71ca230ad521db192dbe47c981ccbd22fc40154aeaaabc8b32b512fb51716783159f55fb171cb71c8e000a245edf833053b374ebac6e91b81f9df45912c43c10
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/scms/changed_file'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
class ChangedFile < ::Avm::Scms::ChangedFile
|
11
|
+
common_constructor :scm, :path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/scms/git/changed_file'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
class ChangedFiles
|
11
|
+
enable_method_class
|
12
|
+
common_constructor :scm
|
13
|
+
|
14
|
+
# @return [Avm::Git::Scms::Git::ChangedFile]
|
15
|
+
def result
|
16
|
+
scm.git_repo.dirty_files.map do |dirty_file|
|
17
|
+
::Avm::Git::Scms::Git::ChangedFile.new(scm, dirty_file.path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -15,11 +15,18 @@ module Avm
|
|
15
15
|
delegate :git_repo, to: :git_scm
|
16
16
|
delegate :id, to: :git_commit
|
17
17
|
|
18
|
+
FIXUP_SUBJECT_PATTERN = /\Afixup\!/.freeze
|
19
|
+
|
18
20
|
# @return [Array<Pathname>]
|
19
21
|
def changed_files
|
20
22
|
git_commit.changed_files.map { |cf| cf.path.to_pathname }
|
21
23
|
end
|
22
24
|
|
25
|
+
# @return [Boolean]
|
26
|
+
def fixup?
|
27
|
+
FIXUP_SUBJECT_PATTERN.match?(git_commit.subject)
|
28
|
+
end
|
29
|
+
|
23
30
|
# @param other [Avm::Git::Scms::Git::Commit]
|
24
31
|
# @return [Avm::Git::Scms::Git::Commit]
|
25
32
|
def merge_with(other)
|
@@ -43,6 +50,9 @@ module Avm
|
|
43
50
|
%w[.gitrepo .gitmodules].any? { |file| file.include?(path.basename.to_path) }
|
44
51
|
end
|
45
52
|
|
53
|
+
# @return [String]
|
54
|
+
delegate :subject, to: :git_commit
|
55
|
+
|
46
56
|
private
|
47
57
|
|
48
58
|
def validate_clean_and_head
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/scms/commit'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
module Commits
|
11
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
12
|
+
def commit(source)
|
13
|
+
if source.is_a?(::Avm::Git::Scms::Git::Commit)
|
14
|
+
return source if source.git_repo == git_repo
|
15
|
+
|
16
|
+
raise 'Not same Git repository'
|
17
|
+
end
|
18
|
+
git_repo.commitize(source).if_present do |v|
|
19
|
+
::Avm::Git::Scms::Git::Commit.new(self, v)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
24
|
+
def commit_dirty(message = nil)
|
25
|
+
return nil unless git_repo.dirty?
|
26
|
+
|
27
|
+
git_repo.command('add', '.').execute!
|
28
|
+
git_repo.command(
|
29
|
+
'commit', '-m',
|
30
|
+
message.call_if_proc.if_present(COMMIT_DIRTY_DEFAULT_MESSAGE)
|
31
|
+
).execute!
|
32
|
+
head_commit
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
36
|
+
def commit_if_change(message = nil)
|
37
|
+
tracker = ::Avm::Git::Scms::Git::ChangeTracker.new(self, message)
|
38
|
+
tracker.start
|
39
|
+
yield
|
40
|
+
tracker.stop
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
44
|
+
def head_commit
|
45
|
+
commit(git_repo.head)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
49
|
+
def reset_and_commit(commit_to_reset, message)
|
50
|
+
git_repo.command('reset', '--soft', commit(commit_to_reset).git_commit.id).execute!
|
51
|
+
commit_dirty(message)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/scms/interval'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
class Interval < ::Avm::Scms::Interval
|
11
|
+
def initialize(scm, from, to)
|
12
|
+
super(scm, from, to)
|
13
|
+
self.from = scm.commit(from)
|
14
|
+
self.to = scm.commit(to)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Array<Avm::Git::Scms::Git::Commit>]
|
18
|
+
def commits
|
19
|
+
scm.git_repo.command('log', '--pretty=format:%H', git_commit_interval).execute!
|
20
|
+
.each_line.map { |sha1| scm.commit(sha1.strip) }
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String]
|
24
|
+
def git_commit_interval
|
25
|
+
[from.id, to.id].join('..')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/scms/commit'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
module Milestones
|
11
|
+
BASE_COMMIT_REFERENCE = 'origin/master'
|
12
|
+
|
13
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
14
|
+
def current_milestone_base_commit
|
15
|
+
commit(BASE_COMMIT_REFERENCE)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/scms/commit'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Scms
|
9
|
+
class Git < ::Avm::Scms::Base
|
10
|
+
class RunCommit
|
11
|
+
enable_method_class
|
12
|
+
|
13
|
+
common_constructor :scm, :commit_info
|
14
|
+
|
15
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
16
|
+
def result
|
17
|
+
reset
|
18
|
+
add_paths
|
19
|
+
commit
|
20
|
+
|
21
|
+
scm.head_commit
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def add_path(path)
|
27
|
+
scm.git_repo.command(
|
28
|
+
*(path.exist? ? ['add'] : ['rm', '-f']),
|
29
|
+
path.relative_path_from(scm.path)
|
30
|
+
).execute!
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_paths
|
34
|
+
commit_info.paths.each { |path| add_path(path) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def commit
|
38
|
+
scm.git_repo.command('commit', *commit_args).execute!
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Array<String>]
|
42
|
+
def commit_args
|
43
|
+
r = commit_info.fixup.if_present([]) { |v| ['--fixup', v.id] }
|
44
|
+
r += commit_info.message.if_present([]) { |v| ['--message', v] }
|
45
|
+
return r if r.any?
|
46
|
+
|
47
|
+
raise 'Argument list is empty'
|
48
|
+
end
|
49
|
+
|
50
|
+
def reset
|
51
|
+
scm.git_repo.command('reset', '--soft', 'HEAD').execute!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/avm/git/scms/git.rb
CHANGED
@@ -8,7 +8,7 @@ module Avm
|
|
8
8
|
module Git
|
9
9
|
module Scms
|
10
10
|
class Git < ::Avm::Scms::Base
|
11
|
-
require_sub __FILE__
|
11
|
+
require_sub __FILE__, include_modules: true
|
12
12
|
include ::Comparable
|
13
13
|
|
14
14
|
COMMIT_DIRTY_DEFAULT_MESSAGE = 'Dirty files.'
|
@@ -17,44 +17,15 @@ module Avm
|
|
17
17
|
git_repo <=> other.git_repo
|
18
18
|
end
|
19
19
|
|
20
|
-
# @return [Avm::Git::Scms::Git::Commit,nil]
|
21
|
-
def commit(source)
|
22
|
-
if source.is_a?(::Avm::Git::Scms::Git::Commit)
|
23
|
-
return source if source.git_repo == self
|
24
|
-
|
25
|
-
raise 'Not same Git repository'
|
26
|
-
end
|
27
|
-
git_repo.commitize(source).if_present do |v|
|
28
|
-
::Avm::Git::Scms::Git::Commit.new(self, v)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Avm::Git::Scms::Git::Commit,nil]
|
33
|
-
def commit_dirty(message = nil)
|
34
|
-
return nil unless git_repo.dirty?
|
35
|
-
|
36
|
-
git_repo.command('add', '.').execute!
|
37
|
-
git_repo.command('commit', '-m',
|
38
|
-
message.call_if_proc.if_present(COMMIT_DIRTY_DEFAULT_MESSAGE)).execute!
|
39
|
-
commit(git_repo.head)
|
40
|
-
end
|
41
|
-
|
42
|
-
# @return [Avm::Git::Scms::Git::Commit,nil]
|
43
|
-
def commit_if_change(message = nil)
|
44
|
-
tracker = ::Avm::Git::Scms::Git::ChangeTracker.new(self, message)
|
45
|
-
tracker.start
|
46
|
-
yield
|
47
|
-
tracker.stop
|
48
|
-
end
|
49
|
-
|
50
20
|
def git_repo
|
51
21
|
@git_repo ||= ::EacGit::Local.new(path)
|
52
22
|
end
|
53
23
|
|
54
|
-
# @
|
55
|
-
|
56
|
-
|
57
|
-
|
24
|
+
# @param from [Avm::Git::Scms::Git::Commit]
|
25
|
+
# @param to [Avm::Git::Scms::Git::Commit]
|
26
|
+
# @return [Avm::Git::Scms::Git::Interval]
|
27
|
+
def interval(from, to)
|
28
|
+
::Avm::Git::Scms::Git::Interval.new(self, from, to)
|
58
29
|
end
|
59
30
|
|
60
31
|
# @return [Enumerable<Avm::Git::Scms::GitSubrepo>]
|
@@ -8,7 +8,8 @@ module Avm
|
|
8
8
|
module Git
|
9
9
|
module Scms
|
10
10
|
class GitSubrepo < ::Avm::Scms::Base
|
11
|
-
delegate :commit_if_change,
|
11
|
+
delegate :changed_files, :commit_if_change, :current_milestone_base_commit, :interval,
|
12
|
+
:head_commit, :run_commit, to: :parent_scm
|
12
13
|
|
13
14
|
def update
|
14
15
|
git_subrepo.command('clean').execute!
|
data/lib/avm/git/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.59'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.59'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: avm-files
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,34 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.110'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.110.1
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - "~>"
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
71
|
+
version: '0.110'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.110.1
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: git
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
81
|
+
version: '1.13'
|
76
82
|
type: :runtime
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
88
|
+
version: '1.13'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: aranha-parsers
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,21 +127,10 @@ extensions: []
|
|
121
127
|
extra_rdoc_files: []
|
122
128
|
files:
|
123
129
|
- lib/avm/git.rb
|
124
|
-
- lib/avm/git/auto_commit/commit_info.rb
|
125
|
-
- lib/avm/git/auto_commit/rules.rb
|
126
|
-
- lib/avm/git/auto_commit/rules/base.rb
|
127
|
-
- lib/avm/git/auto_commit/rules/last.rb
|
128
|
-
- lib/avm/git/auto_commit/rules/manual.rb
|
129
|
-
- lib/avm/git/auto_commit/rules/new.rb
|
130
|
-
- lib/avm/git/auto_commit/rules/nth.rb
|
131
|
-
- lib/avm/git/auto_commit/rules/unique.rb
|
132
|
-
- lib/avm/git/auto_commit_path.rb
|
133
|
-
- lib/avm/git/auto_commit_path/ruby.rb
|
134
130
|
- lib/avm/git/commit.rb
|
135
131
|
- lib/avm/git/commit/class_methods.rb
|
136
132
|
- lib/avm/git/commit/diff_tree_line.rb
|
137
133
|
- lib/avm/git/commit/file.rb
|
138
|
-
- lib/avm/git/file_auto_fixup.rb
|
139
134
|
- lib/avm/git/issue.rb
|
140
135
|
- lib/avm/git/issue/complete.rb
|
141
136
|
- lib/avm/git/issue/complete/commits.rb
|
@@ -182,9 +177,15 @@ files:
|
|
182
177
|
- lib/avm/git/scms.rb
|
183
178
|
- lib/avm/git/scms/git.rb
|
184
179
|
- lib/avm/git/scms/git/change_tracker.rb
|
180
|
+
- lib/avm/git/scms/git/changed_file.rb
|
181
|
+
- lib/avm/git/scms/git/changed_files.rb
|
185
182
|
- lib/avm/git/scms/git/commit.rb
|
186
183
|
- lib/avm/git/scms/git/commit/deploy.rb
|
187
184
|
- lib/avm/git/scms/git/commit/deploy_methods.rb
|
185
|
+
- lib/avm/git/scms/git/commits.rb
|
186
|
+
- lib/avm/git/scms/git/interval.rb
|
187
|
+
- lib/avm/git/scms/git/milestones.rb
|
188
|
+
- lib/avm/git/scms/git/run_commit.rb
|
188
189
|
- lib/avm/git/scms/git_subrepo.rb
|
189
190
|
- lib/avm/git/scms/provider.rb
|
190
191
|
- lib/avm/git/subrepo_check.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
class CommitInfo
|
9
|
-
enable_immutable
|
10
|
-
|
11
|
-
immutable_accessor :fixup, :message
|
12
|
-
|
13
|
-
def git_commit_args
|
14
|
-
r = fixup.if_present([]) { |v| ['--fixup', v.sha1] }
|
15
|
-
r += message.if_present([]) { |v| ['--message', v] }
|
16
|
-
return r if r.any?
|
17
|
-
|
18
|
-
raise 'Argument list is empty'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
module Rules
|
9
|
-
class Base
|
10
|
-
class << self
|
11
|
-
def keys
|
12
|
-
[long_key, short_key]
|
13
|
-
end
|
14
|
-
|
15
|
-
def long_key
|
16
|
-
name.demodulize.variableize
|
17
|
-
end
|
18
|
-
|
19
|
-
def short_key
|
20
|
-
long_key[0, 1]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def with_file(file)
|
25
|
-
self.class.const_get('WithFile').new(self, file)
|
26
|
-
end
|
27
|
-
|
28
|
-
class WithFile
|
29
|
-
common_constructor :rule, :file
|
30
|
-
|
31
|
-
def new_commit_info
|
32
|
-
::Avm::Git::AutoCommit::CommitInfo.new
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/rules/base'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
module Rules
|
9
|
-
class Last < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
-
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
-
def commit_info
|
12
|
-
file.commits.last.if_present { |v| new_commit_info.fixup(v) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/rules/base'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
module Rules
|
9
|
-
class Manual < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
-
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
-
enable_speaker
|
12
|
-
|
13
|
-
COMMIT_FORMAT = '%h - %s (%cr)'
|
14
|
-
SKIP_OPTION = 's'
|
15
|
-
|
16
|
-
def commit_info
|
17
|
-
return nil unless file.commits.any?
|
18
|
-
|
19
|
-
commits_banner
|
20
|
-
input('Which commit?', list: commits_by_position).if_present do |v|
|
21
|
-
new_commit_info.fixup(v)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def commits_banner
|
26
|
-
file.commits.each_with_index do |commit, _index|
|
27
|
-
infov " #{commit.position}", format_commit(commit)
|
28
|
-
end
|
29
|
-
infov " #{SKIP_OPTION}", 'skip'
|
30
|
-
end
|
31
|
-
|
32
|
-
def commits_by_position
|
33
|
-
(file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]])
|
34
|
-
.to_h
|
35
|
-
end
|
36
|
-
|
37
|
-
def format_commit(commit)
|
38
|
-
commit.format(COMMIT_FORMAT)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/rules/base'
|
4
|
-
require 'avm/git/auto_commit_path'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Git
|
8
|
-
module AutoCommit
|
9
|
-
module Rules
|
10
|
-
class New < ::Avm::Git::AutoCommit::Rules::Base
|
11
|
-
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
12
|
-
def auto_commit_path
|
13
|
-
::Avm::Git::AutoCommitPath.new(file.git, file.path)
|
14
|
-
end
|
15
|
-
|
16
|
-
def commit_info
|
17
|
-
new_commit_info.message(auto_commit_path.commit_message)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/rules/base'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
module Rules
|
9
|
-
class Nth < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
-
SHORT_KEY = 't'
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def short_key
|
14
|
-
SHORT_KEY
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
common_constructor :number do
|
19
|
-
self.number = number.to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
23
|
-
def commit_info
|
24
|
-
file.commits(number - 1).if_present { |v| new_commit_info.fixup(v) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/rules/base'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
module AutoCommit
|
8
|
-
module Rules
|
9
|
-
class Unique < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
-
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
-
def commit_info
|
12
|
-
return nil unless file.commits.count == 1
|
13
|
-
|
14
|
-
new_commit_info.fixup(file.commits.first)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
::EacRubyUtils.require_sub __FILE__
|
6
|
-
|
7
|
-
module Avm
|
8
|
-
module Git
|
9
|
-
module AutoCommit
|
10
|
-
module Rules
|
11
|
-
RULES_CLASSES = %w[last manual new nth unique]
|
12
|
-
.map { |key| ::Avm::Git::AutoCommit::Rules.const_get(key.camelcase) }
|
13
|
-
|
14
|
-
class << self
|
15
|
-
def parse(string)
|
16
|
-
parts = string.split(':')
|
17
|
-
|
18
|
-
klass = rule_class_by_key(parts.shift)
|
19
|
-
klass.new(*parts)
|
20
|
-
end
|
21
|
-
|
22
|
-
def rule_class_by_key(key)
|
23
|
-
RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
|
24
|
-
raise("Rule not find with key \"#{key}\" (Available: " +
|
25
|
-
RULES_CLASSES.flat_map(&:keys).join(', ') + ')')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
class AutoCommitPath
|
8
|
-
module Ruby
|
9
|
-
RUBY_CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
|
10
|
-
|
11
|
-
def ruby_class_name
|
12
|
-
RUBY_CLASS_NAME_PATTERNS.each do |pattern|
|
13
|
-
pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
|
14
|
-
end
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Git
|
7
|
-
class AutoCommitPath
|
8
|
-
require_sub __FILE__, include_modules: true
|
9
|
-
common_constructor :git, :path do
|
10
|
-
self.path = path.to_pathname
|
11
|
-
end
|
12
|
-
|
13
|
-
def class_name
|
14
|
-
ruby_class_name || relative_path.to_path
|
15
|
-
end
|
16
|
-
|
17
|
-
def commit_message
|
18
|
-
r = class_name
|
19
|
-
r += ': remove' unless path.file?
|
20
|
-
r + '.'
|
21
|
-
end
|
22
|
-
|
23
|
-
def relative_path
|
24
|
-
path.expand_path.relative_path_from(git.root_path.expand_path)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/git/auto_commit/commit_info'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Git
|
8
|
-
class FileAutoFixup
|
9
|
-
enable_speaker
|
10
|
-
enable_simple_cache
|
11
|
-
enable_listable
|
12
|
-
|
13
|
-
common_constructor :git, :path, :rules do
|
14
|
-
self.path = path.to_pathname.expand_path(git.root_path)
|
15
|
-
end
|
16
|
-
|
17
|
-
COMMITS_SEARCH_INTERVAL = 'origin/master..HEAD'
|
18
|
-
|
19
|
-
def git_relative_path
|
20
|
-
path.to_pathname.relative_path_from(git.root_path)
|
21
|
-
end
|
22
|
-
|
23
|
-
def run
|
24
|
-
start_banner
|
25
|
-
run_commit || warn("No rule returned commit information for \"#{path}\"")
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def commit_args
|
31
|
-
commit_info.if_present([], &:git_commit_args) + ['--', git_relative_path]
|
32
|
-
end
|
33
|
-
|
34
|
-
def commit_info_uncached
|
35
|
-
rules.lazy.map { |rule| rule.with_file(self).commit_info }.find(&:present?)
|
36
|
-
end
|
37
|
-
|
38
|
-
def start_banner
|
39
|
-
infov 'Path', path
|
40
|
-
infov ' Commits found', commits.count
|
41
|
-
end
|
42
|
-
|
43
|
-
def run_commit
|
44
|
-
return false if commit_info.blank?
|
45
|
-
|
46
|
-
infov ' Commit arguments', ::Shellwords.join(commit_args)
|
47
|
-
run_git_add_and_commit
|
48
|
-
success ' Commited'
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
def run_git_add_and_commit
|
53
|
-
git.execute!('reset', '--soft', 'HEAD')
|
54
|
-
if path.exist?
|
55
|
-
git.execute!('add', git_relative_path)
|
56
|
-
else
|
57
|
-
git.execute!('rm', '-f', git_relative_path)
|
58
|
-
end
|
59
|
-
git.execute!('commit', *commit_args)
|
60
|
-
end
|
61
|
-
|
62
|
-
def commits_uncached
|
63
|
-
git.execute!('log', '--pretty=format:%H', COMMITS_SEARCH_INTERVAL, '--', path)
|
64
|
-
.each_line.map { |sha1| ::Avm::Git::Commit.new(git, sha1.strip) }
|
65
|
-
.reject { |commit| commit.subject.start_with?('fixup!') }
|
66
|
-
.each_with_index.map { |commit, index| CommitDelegator.new(commit, index) }
|
67
|
-
end
|
68
|
-
|
69
|
-
class CommitDelegator < ::SimpleDelegator
|
70
|
-
attr_reader :index
|
71
|
-
|
72
|
-
def initialize(commit, index)
|
73
|
-
super(commit)
|
74
|
-
@index = index
|
75
|
-
end
|
76
|
-
|
77
|
-
def position
|
78
|
-
index + 1
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|