meta_commit 0.2.0.pre.alpha → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fcc0c263c146decf38b057cba6b6afb68307237
4
- data.tar.gz: 065807ac6a1848a434c586893173a4edf3e97ab8
3
+ metadata.gz: 714f1ef542aa5c01085288e1d02eafb8e405a0bf
4
+ data.tar.gz: 40cd2dab04ce2a9c597411cbfc5c22d2c480870d
5
5
  SHA512:
6
- metadata.gz: fb11ea9ca1c203df6a264bf2e8343c003521017c0a22cc5b93a811d1f7d0515b95a2cc5134a88b9fe735359d8c9b4a16861eeab5e3fc7d02243dd8fa0a8fe81f
7
- data.tar.gz: 4b53eb6e6a3c3d2ac0be8e556035e6e0103591692ea8e515b72c70e49a007fdac4a4ffd88fb0d92218c9f5eb8ad75ad79ae4724288d7ace91809827456099f3f
6
+ metadata.gz: 91f560c202ff6675cd68a3f4375072928687201c8dd8733ae23371cd61a2c8e4a1df7fa935846bbedfe7f58da5fd94601be5e4b96b49aa9842db7b1bef080754
7
+ data.tar.gz: 8468bd6fea1b6732fa04269f4561b8bc8c354fd1a55856ad2c59032477f8b5e4f6a492c152917ab5107cca79a96225582e90a21a127162ffc90a0ad540dcb533
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 0.2.0 - 2017-10-25
8
+ ### Added
9
+ - Code documentation
10
+ - Contribution guide
11
+ - Configuration using `.meta_commit.yml` file
12
+ - Handle `MissingRepoError` error
13
+
14
+ ### Changed
15
+ - Dynamically include extensions
16
+ - Directory parameter is not longer required for commands, cli receives directory via `--directory` option
17
+
18
+ ### Removed
19
+ - Extract ruby specific diffs and parser to separate [extension](https://github.com/meta-commit/ruby_support)
20
+ - Extract contracts to separate [gem](https://github.com/meta-commit/contracts)
21
+ - Delete base diff class
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Description
11
11
 
12
- [![v0.1 demonstration](https://asciinema.org/a/6nlvujsgeoa1xtp9l9qhx8lry.png)](https://asciinema.org/a/6nlvujsgeoa1xtp9l9qhx8lry?autoplay=1)
12
+ [![v0.2 demonstration](https://asciinema.org/a/svV2TBICPgp7pOWneRI30WDel.png)](https://asciinema.org/a/svV2TBICPgp7pOWneRI30WDel?autoplay=1)
13
13
 
14
14
  meta commit - is set of commands for git repository, which extracts useful information from commits and allows to get more insights from usual actions with repository.
15
15
 
@@ -54,13 +54,13 @@ Elements of `extensions` list are gem names (without `meta_commit_` prefix) that
54
54
 
55
55
  ### Message
56
56
 
57
- meta_commit message [--repo=$(pwd)]
57
+ meta_commit message [--directory=$(pwd)]
58
58
 
59
59
  Prints description of current changes in repository index
60
60
 
61
61
  ### Index
62
62
 
63
- meta_commit index [--repo=$(pwd)]
63
+ meta_commit index [--directory=$(pwd)]
64
64
 
65
65
  Walks over repository commits and writes meta information to git notes
66
66
 
data/exe/meta_commit CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -wU -W0
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  require 'meta_commit'
4
4
 
@@ -20,7 +20,7 @@ module MetaCommit::Changelog
20
20
 
21
21
  # Builds changelog message and adds it after description text and before latest version
22
22
  # @param repo
23
- # @param [Array<MetaCommit::Models::Diffs::Diff>] diffs
23
+ # @param [Array<MetaCommit::Contracts::Diff>] diffs
24
24
  # @return [String]
25
25
  def write_repository_change_chunk(repo, diffs)
26
26
  message_builder = changelog_message_builder(@tag, @date)
@@ -15,7 +15,7 @@ module MetaCommit::Changelog
15
15
  # @param [MetaCommit::Git::Repo] repo
16
16
  # @param [String] left_commit commit id
17
17
  # @param [String] right_commit commit id
18
- # @return [Array<MetaCommit::Models::Diffs::Diff>]
18
+ # @return [Array<MetaCommit::Contracts::Diff>]
19
19
  def meta(repo, left_commit, right_commit)
20
20
  diffs = []
21
21
  commit_id_old = left_commit.oid
@@ -60,7 +60,7 @@ module MetaCommit::Changelog
60
60
  def changes_group_entry(type, changes)
61
61
  header = ["### #{type}"]
62
62
  list = changes.map { |change| "- #{change}" }
63
- ([header] + list).join("\n")
63
+ ([header] + list).uniq.join("\n")
64
64
  end
65
65
 
66
66
  private :changes_group_entry
@@ -5,6 +5,8 @@ module MetaCommit::Git
5
5
  # @attr [Rugged::Repository] repo
6
6
  class Repo
7
7
  DIFF_OPTIONS = {:context_lines => 0, :ignore_whitespace => true}
8
+ INDEX_DIFF_OPTIONS = {:context_lines => 0, :ignore_whitespace => true, :reverse => true}
9
+
8
10
  FILE_NOT_EXISTS_OID = '0000000000000000000000000000000000000000'
9
11
 
10
12
  attr_accessor :repo
@@ -72,7 +74,7 @@ module MetaCommit::Git
72
74
  # @yield [old_file_path, new_file_path, patch, line]
73
75
  # @return [Object]
74
76
  def index_diff_with_optimized_lines
75
- diff = index_diff(DIFF_OPTIONS)
77
+ diff = index_diff(INDEX_DIFF_OPTIONS)
76
78
  diff.deltas.zip(diff.patches).each do |delta, patch|
77
79
  lines = organize_lines(delta, patch)
78
80
  lines.each do |line|
@@ -18,7 +18,7 @@ module MetaCommit::Index
18
18
  commit_changes.file_changes.uniq.each do |change|
19
19
  diffs.push(" - #{change.string_representation}")
20
20
  end
21
- write_to_notes(commit_changes.new_commit_id, diffs.join("\n"))
21
+ write_to_notes(commit_changes.new_commit_id, diffs.uniq.join("\n"))
22
22
  end
23
23
  end
24
24
 
@@ -23,7 +23,7 @@ module MetaCommit::Index
23
23
  repo_changes
24
24
  end
25
25
 
26
- # @return [Array<MetaCommit::Models::Diffs::Diff>]
26
+ # @return [Array<MetaCommit::Contracts::Diff>]
27
27
  def examine_diff(repo, left_commit, right_commit)
28
28
  diffs = []
29
29
  repo.diff_with_optimized_lines(left_commit, right_commit) do |old_file_path, new_file_path, patch, line|
@@ -12,7 +12,7 @@ module MetaCommit::Message
12
12
 
13
13
  # Creates diff objects with meta information of changes in index staged files
14
14
  # @param [MetaCommit::Git::Repo] repo
15
- # @return [Array<MetaCommit::Models::Diffs::Diff>]
15
+ # @return [Array<MetaCommit::Contracts::Diff>]
16
16
  def index_meta(repo)
17
17
  diffs = MetaCommit::Models::Changes::Commit.new(repo.last_commit_oid, 'staged')
18
18
  repo.index_diff_with_optimized_lines do |old_file_path, new_file_path, patch, line|
@@ -2,14 +2,14 @@ module MetaCommit::Message
2
2
  module Formatters
3
3
  # Class builds message to commit changes
4
4
  class CommitMessageBuilder
5
- # @param [Array<MetaCommit::Models::Diffs::Diff>] diffs
5
+ # @param [Array<MetaCommit::Contracts::Diff>] diffs
6
6
  # @return [String]
7
7
  def build(diffs)
8
- result = ''
8
+ result = []
9
9
  diffs.each do |diff|
10
10
  result << "- #{diff.string_representation} \n"
11
11
  end
12
- result
12
+ result.uniq.join
13
13
  end
14
14
  end
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module MetaCommit
2
- VERSION = "0.2.0.pre.alpha"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/meta_commit.rb CHANGED
@@ -28,7 +28,6 @@ module MetaCommit
28
28
  require "meta_commit/models/line"
29
29
  require "meta_commit/models/changes/commit"
30
30
  require "meta_commit/models/changes/repository"
31
- require "meta_commit/models/diffs/diff"
32
31
 
33
32
  # factories
34
33
  require "meta_commit/factories/diff_factory"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre.alpha
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav Dobrovolskiy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-10-17 00:00:00.000000000 Z
12
+ date: 2017-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: meta_commit_contracts
@@ -204,6 +204,7 @@ extra_rdoc_files: []
204
204
  files:
205
205
  - ".gitignore"
206
206
  - ".travis.yml"
207
+ - CHANGELOG.md
207
208
  - CODE_OF_CONDUCT.md
208
209
  - CONTRIBUTING.md
209
210
  - Gemfile
@@ -234,7 +235,6 @@ files:
234
235
  - lib/meta_commit/models/changes/commit.rb
235
236
  - lib/meta_commit/models/changes/repository.rb
236
237
  - lib/meta_commit/models/contextual_ast_node.rb
237
- - lib/meta_commit/models/diffs/diff.rb
238
238
  - lib/meta_commit/models/line.rb
239
239
  - lib/meta_commit/services/change_saver.rb
240
240
  - lib/meta_commit/services/parse.rb
@@ -255,9 +255,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
- - - ">"
258
+ - - ">="
259
259
  - !ruby/object:Gem::Version
260
- version: 1.3.1
260
+ version: '0'
261
261
  requirements: []
262
262
  rubyforge_project:
263
263
  rubygems_version: 2.5.1
@@ -1,62 +0,0 @@
1
- module MetaCommit::Models::Diffs
2
- # Base class for diffs
3
- # @attr [Symbol] diff_type
4
- # @attr [String] commit_old
5
- # @attr [String] commit_new
6
- # @attr [String] old_file
7
- # @attr [String] new_file
8
- # @attr [String] old_lineno
9
- # @attr [String] new_lineno
10
- # @attr [MetaCommit::Models::ContextualAstNode] old_ast_path
11
- # @attr [MetaCommit::Models::ContextualAstNode] new_ast_path
12
- class Diff
13
-
14
- TYPE_ADDITION = :addition
15
- TYPE_DELETION = :deletion
16
- TYPE_REPLACE = :replace
17
-
18
- attr_accessor :diff_type
19
- attr_accessor :commit_old, :commit_new
20
- attr_accessor :old_file, :new_file
21
- attr_accessor :old_lineno, :new_lineno
22
- attr_accessor :old_ast_path, :new_ast_path
23
-
24
- # @return [String]
25
- def inspect
26
- string_representation
27
- end
28
-
29
- # @return [String]
30
- def to_s
31
- string_representation
32
- end
33
-
34
- # @return [String]
35
- def string_representation
36
- "#{diff_type} was performed"
37
- end
38
-
39
- # @param [Symbol] type
40
- # @param [String] old_file_name
41
- # @param [String] new_file_name
42
- # @param [String] old_ast_path
43
- # @param [String] new_ast_path
44
- # @return [Boolean]
45
- def supports_change(type, old_file_name, new_file_name, old_ast_path, new_ast_path)
46
- true
47
- end
48
-
49
- # @return [Boolean]
50
- def type_addition?
51
- @diff_type == TYPE_ADDITION
52
- end
53
- # @return [Boolean]
54
- def type_deletion?
55
- @diff_type == TYPE_DELETION
56
- end
57
- # @return [Boolean]
58
- def type_replace?
59
- @diff_type == TYPE_REPLACE
60
- end
61
- end
62
- end