valr 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/valr +12 -0
- data/lib/.gitignore +0 -0
- data/lib/valr.rb +1 -0
- data/lib/valr/empty_repository_error.rb +9 -0
- data/lib/valr/not_valid_range_error.rb +9 -0
- data/lib/valr/repo.rb +114 -0
- data/lib/valr/repository_error.rb +9 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa865dd364c0adf88f274215c451e9555adde10f
|
4
|
+
data.tar.gz: ff22dbc0f83d3f67b9c4a5eb9f61d5500c24f0fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d599ef8a64bf0925eab3085a2d93902e856fba959c0738f4bf9db93c07b6c7c6b0961a52b8ee79816140696f2f9d1f3019446701266132169b0b12b3b9968fa
|
7
|
+
data.tar.gz: 78eeb823d6fcef9152f8a698d134aaa394998e3a19bf0250ae278b844190aaa05b0573de3b6a91225ca4603e7ee8be143b4e1a031703d1e1d38186a7ff6c1fb1
|
data/bin/valr
ADDED
data/lib/.gitignore
ADDED
File without changes
|
data/lib/valr.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'valr/repo'
|
data/lib/valr/repo.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'rugged'
|
2
|
+
require 'valr/repository_error'
|
3
|
+
require 'valr/empty_repository_error'
|
4
|
+
require 'valr/not_valid_range_error'
|
5
|
+
|
6
|
+
module Valr
|
7
|
+
class Repo
|
8
|
+
# Initialize new Valr for a git repository
|
9
|
+
# @param [String] repo_path Path of git repository
|
10
|
+
def initialize(repo_path)
|
11
|
+
@repo_path = repo_path
|
12
|
+
begin
|
13
|
+
@repo = Rugged::Repository.new @repo_path
|
14
|
+
rescue Rugged::RepositoryError => e
|
15
|
+
raise Valr::RepositoryError.new @repo_path
|
16
|
+
end
|
17
|
+
raise Valr::EmptyRepositoryError.new @repo_path if @repo.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get the changelog based on commit messages.
|
21
|
+
# @param [Boolean] first_parent Optional, if true limits to first parent commits
|
22
|
+
# @param [String] range Optional, define a specific range of commits
|
23
|
+
# @return [String] changelog
|
24
|
+
def changelog(first_parent: false, range: nil)
|
25
|
+
to_list(first_lines(log_messages first_parent, range))
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get the full changelog including metadata.
|
29
|
+
# @param [Boolean] first_parent Optional, if true limits to first parent commits
|
30
|
+
# @param [String] range Optional, define a specific range of commits
|
31
|
+
# @return [String] changelog
|
32
|
+
def full_changelog(first_parent: false, range: nil)
|
33
|
+
if range.nil?
|
34
|
+
full_changelog_no_range first_parent
|
35
|
+
else
|
36
|
+
full_changelog_range first_parent, range
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Array to markdown list
|
43
|
+
# @param [Array<String>] items
|
44
|
+
# @return [String] markdown list
|
45
|
+
def to_list(items)
|
46
|
+
(items.map {|item| "- #{item}"}).join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Extract only first lines
|
50
|
+
# @param [Array<String>] strings
|
51
|
+
# @return [Array<String>] Array of first lines
|
52
|
+
def first_lines(strings)
|
53
|
+
strings.map {|string|
|
54
|
+
string.split("\n").first
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get log messages for a repository
|
59
|
+
# @param [Boolean] first_parent Optional, if true limit to first parent commits
|
60
|
+
# @param [String] range Optional, define a specific range of commits
|
61
|
+
# @return [Array<String>] log messages
|
62
|
+
def log_messages(first_parent = false, range = nil)
|
63
|
+
walker = Rugged::Walker.new @repo
|
64
|
+
if range.nil?
|
65
|
+
walker.push @repo.head.target_id
|
66
|
+
else
|
67
|
+
begin
|
68
|
+
walker.push_range range
|
69
|
+
rescue Rugged::ReferenceError => e
|
70
|
+
raise Valr::NotValidRangeError.new range
|
71
|
+
end
|
72
|
+
end
|
73
|
+
walker.simplify_first_parent if first_parent
|
74
|
+
messages = walker.inject([]) { |messages, c| messages << c.message }
|
75
|
+
walker.reset
|
76
|
+
messages
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get the full changelog including metadata.
|
80
|
+
# @param [Boolean] first_parent If true limits to first parent commits
|
81
|
+
# @return [String] changelog
|
82
|
+
def full_changelog_no_range(first_parent)
|
83
|
+
%{#{last_sha1}
|
84
|
+
|
85
|
+
#{changelog(first_parent: first_parent)}}
|
86
|
+
end
|
87
|
+
|
88
|
+
# Get the full changelog including metadata.
|
89
|
+
# @param [Boolean] first_parent If true limits to first parent commits
|
90
|
+
# @param [String] range Define a specific range of commits
|
91
|
+
# @return [String] changelog
|
92
|
+
def full_changelog_range(first_parent, range)
|
93
|
+
changelog_list = changelog first_parent: first_parent, range: range
|
94
|
+
from, to = range.split '..'
|
95
|
+
from_commit, to_commit = [from, to].map { |ref| rev_parse ref }
|
96
|
+
%{ from: #{from} <#{from_commit.oid}>
|
97
|
+
to: #{to} <#{to_commit.oid}>
|
98
|
+
|
99
|
+
#{changelog_list}}
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get the last sha1 of a git repository
|
103
|
+
def last_sha1
|
104
|
+
@repo.head.target_id
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get the commit of a reference (tag or other)
|
108
|
+
# @param [String] ref Reference to get the commit
|
109
|
+
# @return the commit
|
110
|
+
def rev_parse(ref)
|
111
|
+
Rugged::Object.rev_parse @repo, ref
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: valr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yves Brissaud
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.3.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.3.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: guard
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.13'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.13.0
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.13'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.13.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: guard-rspec
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '4.6'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.6.4
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.6'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 4.6.4
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: simplecov
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.10'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.10.0
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.10.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rugged
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.23.2
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.23.2
|
107
|
+
description: A markdown powered CHANGELOG generator using git commit messages.
|
108
|
+
email: yves.brissaud@gmail.com
|
109
|
+
executables:
|
110
|
+
- valr
|
111
|
+
extensions: []
|
112
|
+
extra_rdoc_files: []
|
113
|
+
files:
|
114
|
+
- bin/valr
|
115
|
+
- lib/.gitignore
|
116
|
+
- lib/valr.rb
|
117
|
+
- lib/valr/empty_repository_error.rb
|
118
|
+
- lib/valr/not_valid_range_error.rb
|
119
|
+
- lib/valr/repo.rb
|
120
|
+
- lib/valr/repository_error.rb
|
121
|
+
homepage: https://github.com/eunomie/valr
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.4.8
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Changelog generator
|
145
|
+
test_files: []
|