gfsm 0.3.0 → 0.3.2

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
  SHA256:
3
- metadata.gz: b9e0ba6497503d24cc631e5a561879a5b8fddd9b0b98243b4b92d2f05f5add90
4
- data.tar.gz: ac56fb2b77daf823e235cf7c06e6ca8ad29d585f261e83a90506efe7a3f30fd2
3
+ metadata.gz: a3daf635392e3b39f025cb94e1a4d73b6d28be9a763e2772b125926414197a81
4
+ data.tar.gz: 417a58de2b92bdefd1328ea4ebd812dcc9d2576456e69ad5076eb8ec0eb9ae69
5
5
  SHA512:
6
- metadata.gz: 99373328bcc6e18fa2bd4c588a98fca5ff359fa83c2f1281049236a23f5f8631aafb9676ab813461dd2a6b87a89a83a3b595cc81db9d7266f141d412ca0c8f61
7
- data.tar.gz: 1928c819f0a3bc20d324cacfb038506ed6eaf0cacb425070bcd09c4f85ea65bde18374cd4029aa2808552b2e6a71f4e46169811a3404e034177f9c0c32a2ab66
6
+ metadata.gz: bb531a7d063939b9aa8da7b00ae64f9050c5da0000540e9b8284415006608ff33d7e528e1f02a2e5ab7150879c807272690fb1394e9f8e7da8e36596fa57af26
7
+ data.tar.gz: 04da15d2f22e288c0caa21d52788807364762ff8ce88edcabe5677ff4c2c29ed3fbc56a553424d246560eec9ccd25704a1d9750e8244ada5c35e7d5f23fbc8c4
data/lib/gfsm.rb CHANGED
@@ -7,11 +7,11 @@ require 'data/configuration'
7
7
  require 'data/version'
8
8
 
9
9
  # Load the tools
10
- require 'tools/commits_extractor'
11
10
  require 'tools/commits_subdivider'
12
11
  require 'tools/current_version_loader'
13
- require 'tools/version_bumper'
12
+ require 'tools/git_utilities'
14
13
  require 'tools/output'
14
+ require 'tools/version_bumper'
15
15
 
16
16
  # Load the commands
17
17
  require 'commands/base_command'
@@ -7,13 +7,9 @@ module GFSM
7
7
  module Tools
8
8
  class CurrentVersionLoader
9
9
  def self.load_current_version(repo_path = ".")
10
- repo = Git.open(repo_path)
11
-
12
- begin
13
- last_tag_name = repo.describe(nil, { :tags => true, :abbrev => 0 })
14
- rescue
15
- last_tag_name = nil
16
- end
10
+ last_tag_name = GFSM::Tools::GitUtilities.extract_last_tag_name(
11
+ GFSM::Tools::GitUtilities.load_repo(repo_path)
12
+ )
17
13
 
18
14
  return GFSM::Data::Version.new("0.0.0") unless last_tag_name
19
15
 
@@ -4,17 +4,29 @@ require 'git'
4
4
 
5
5
  module GFSM
6
6
  module Tools
7
- class CommitsExtractor
7
+ class GitUtilities
8
8
  CHANGELOG_TRAILER_REGEX = /^(?<name>Changelog):\s*(?<category>.+)$/i
9
9
 
10
- def self.extract_commits_with_changelog_trailer(repo_path = ".")
11
- repo = Git.open(repo_path)
10
+ def self.load_repo(repo_path)
11
+ Git.open(repo_path)
12
+ end
12
13
 
14
+ def self.extract_last_tag_name(repo)
13
15
  begin
14
- last_tag_name = repo.describe(nil, { :tags => true, :abbrev => 0 })
16
+ current_sort_order = repo.config("tag.sort")
17
+ repo.fetch(tags: true)
18
+
19
+ repo.config("tag.sort", "-v:refname")
20
+ tags = repo.tags
21
+ repo.config("tag.sort", current_sort_order)
22
+
23
+ tags[0].name if !tags.empty?
15
24
  rescue
16
- last_tag_name = nil
17
25
  end
26
+ end
27
+
28
+ def self.extract_commits_with_changelog_trailer(repo)
29
+ last_tag_name = self.extract_last_tag_name(repo)
18
30
 
19
31
  begin
20
32
  commits = last_tag_name ? repo.log.between(last_tag_name, 'HEAD') : repo.log
@@ -10,7 +10,9 @@ module GFSM
10
10
 
11
11
  def compute_version!(force, prerelease, prerelease_name, repository_path, configuration_file_path)
12
12
  configuration = GFSM::Data::Configuration.new(configuration_file_path)
13
- changelog_commits = GFSM::Tools::CommitsExtractor.extract_commits_with_changelog_trailer(repository_path)
13
+ changelog_commits = GFSM::Tools::GitUtilities.extract_commits_with_changelog_trailer(
14
+ GFSM::Tools::GitUtilities.load_repo(repository_path)
15
+ )
14
16
 
15
17
  @version = GFSM::Tools::CurrentVersionLoader.load_current_version(repository_path)
16
18
  @subdivisions = GFSM::Tools::CommitsSubdivider.subdivide_commits(configuration, changelog_commits)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gfsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zille Marco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -81,9 +81,9 @@ files:
81
81
  - lib/data/configuration.rb
82
82
  - lib/data/version.rb
83
83
  - lib/gfsm.rb
84
- - lib/tools/commits_extractor.rb
85
84
  - lib/tools/commits_subdivider.rb
86
85
  - lib/tools/current_version_loader.rb
86
+ - lib/tools/git_utilities.rb
87
87
  - lib/tools/output.rb
88
88
  - lib/tools/version_bumper.rb
89
89
  homepage: https://gitlab.com/zillemarco/gitlab-flavored-semantic-versioning