sem_ver_components 0.1.2 → 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
  SHA256:
3
- metadata.gz: c9da50f9edee211f731452cdfb03e376d2b895f75d04a5ebdbfe2d30c87dfb90
4
- data.tar.gz: 1ad69a75e32306303ae841aa9aecf633a7c90db25cd529d9c8c791837e154e04
3
+ metadata.gz: c769d2f50e4b9b47d7244d596c497781797539059ae577b3922221a0b55fdfb4
4
+ data.tar.gz: c265fe89c722f6092b0f8061ea556244131f1d3ce13de0ba24c2fb0714e05d04
5
5
  SHA512:
6
- metadata.gz: d4b54b6a41a4060da5171f2f809ca57aac59d75a72194da62b84d6e1a598f40e0ea29682221fdb0fda163db6dc494dcaf7dcd74b52fdbea6b20b167af3cc75b7
7
- data.tar.gz: 2111a729b803e12870b3df2d1e4efc2411d34deeff6882218b2313b17686748d8350f47f56a89a39f12b5c0d997b3caef7ec4134e7c57462dc05f0704605694b
6
+ metadata.gz: fc08045f4e3552af8deefe3e4086b8d9e4e80c39bfe65a2c00a8ab25b7eeccbcf089207adcdcb5832308abaa3a2008343c393a124dba4948f8a49b0e161e82d6
7
+ data.tar.gz: 021e88d06a2ce6fc31cb5d146e211c9436db6ec4da7eaafd151ce16df08347f179cd286782d42e4f10cfeb89f668bac14420a91786e449d757c51205f2b70905
@@ -4,18 +4,24 @@ require 'sem_ver_components/plugins'
4
4
  require 'sem_ver_components/local_git'
5
5
  require 'sem_ver_components/version'
6
6
  require 'sem_ver_components/output'
7
+ require 'sem_ver_components/git_hosting'
7
8
 
8
9
  # Default values
9
10
  git_repo = '.'
10
11
  git_from = nil
11
12
  git_to = 'HEAD'
13
+ git_hosting = :github
12
14
  output = :info
13
15
  output_plugins = SemVerComponents::Plugins.new(:outputs)
16
+ git_hosting_plugins = SemVerComponents::Plugins.new(:git_hostings)
14
17
  OptionParser.new do |opts|
15
18
  opts.banner = "Usage: #{File.basename($0)} [options]"
16
19
  opts.on('-f', '--from GIT_REF', 'Git reference from which commits are to be analyzed (defaults to first commit)') do |git_ref|
17
20
  git_from = git_ref
18
21
  end
22
+ opts.on('-g', '--git_hosting GIT_HOSTING', "Specify which kind of git hosting is used. Used to format URLs to commits and comparisons. Possible values are #{git_hosting_plugins.list.sort.join(', ')}. (defaults to #{git_hosting})") do |git_hosting_str|
23
+ git_hosting = git_hosting_str.to_sym
24
+ end
19
25
  opts.on('-h', '--help', 'Display this help') do
20
26
  puts opts
21
27
  exit 0
@@ -40,4 +46,4 @@ raise "Unknown parameters: #{ARGV.join(' ')}" unless ARGV.empty?
40
46
  local_git = SemVerComponents::LocalGit.new(git_repo, git_from, git_to)
41
47
  commits_info = local_git.analyze_commits
42
48
 
43
- output_plugins[output].new(local_git).process(commits_info)
49
+ output_plugins[output].new(local_git, git_hosting_plugins[git_hosting].new).process(commits_info)
@@ -0,0 +1,8 @@
1
+ module SemVerComponents
2
+
3
+ # Base class for all git hosting plugins
4
+ class GitHosting
5
+
6
+ end
7
+
8
+ end
@@ -0,0 +1,30 @@
1
+ module SemVerComponents
2
+
3
+ module GitHostings
4
+
5
+ class Bitbucket < GitHosting
6
+
7
+ # Get the URL to a given commit sha
8
+ #
9
+ # Parameters::
10
+ # * *git_url* (String): The git URL
11
+ # * *commit_sha* (String): The commit sha
12
+ def commit_url(git_url, commit_sha)
13
+ "#{git_url}/commits/#{commit_sha}"
14
+ end
15
+
16
+ # Get the URL to compare 2 tags
17
+ #
18
+ # Parameters::
19
+ # * *git_url* (String): The git URL
20
+ # * *tag_1* (String): The first tag
21
+ # * *tag_2* (String): The second tag
22
+ def compare_url(git_url, tag_1, tag_2)
23
+ "#{git_url}/compare/commits?targetBranch=refs%2Ftags%2F#{tag_2}&sourceBranch=refs%2Ftags%2F#{tag_1}"
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,30 @@
1
+ module SemVerComponents
2
+
3
+ module GitHostings
4
+
5
+ class Github < GitHosting
6
+
7
+ # Get the URL to a given commit sha
8
+ #
9
+ # Parameters::
10
+ # * *git_url* (String): The git URL
11
+ # * *commit_sha* (String): The commit sha
12
+ def commit_url(git_url, commit_sha)
13
+ "#{git_url}/commit/#{commit_sha}"
14
+ end
15
+
16
+ # Get the URL to compare 2 tags
17
+ #
18
+ # Parameters::
19
+ # * *git_url* (String): The git URL
20
+ # * *tag_1* (String): The first tag
21
+ # * *tag_2* (String): The second tag
22
+ def compare_url(git_url, tag_1, tag_2)
23
+ "#{git_url}/compare/#{tag_1}...#{tag_2}"
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -1,13 +1,16 @@
1
1
  module SemVerComponents
2
2
 
3
+ # Base class for all output plugins
3
4
  class Output
4
5
 
5
6
  # Constructor
6
7
  #
7
8
  # Parameters::
8
9
  # * *local_git* (LocalGit): The git repository
9
- def initialize(local_git)
10
+ # * *git_hosting* (GitHosting): The git hosting to be used for URLs
11
+ def initialize(local_git, git_hosting)
10
12
  @local_git = local_git
13
+ @git_hosting = git_hosting
11
14
  end
12
15
 
13
16
  end
@@ -80,7 +80,7 @@ module SemVerComponents
80
80
  commits_per_component[component][bump_level] << git_commit
81
81
  end
82
82
  end
83
- puts "# [v#{new_version}](#{git_url}/compare/#{@local_git.git_from}...v#{new_version}) (#{Time.now.utc.strftime('%F %T')})"
83
+ puts "# [v#{new_version}](#{@git_hosting.compare_url(git_url, @local_git.git_from, new_version)}) (#{Time.now.utc.strftime('%F %T')})"
84
84
  puts
85
85
  commits_per_component.sort_by { |component, _component_info| component || '' }.each do |(component, component_info)|
86
86
  puts "## #{component.nil? ? 'Global changes' : "Changes for #{component}"}\n" if commits_per_component.size > 1 || !component.nil?
@@ -112,7 +112,7 @@ module SemVerComponents
112
112
  commit_lines[commit_line] = commit.sha
113
113
  end
114
114
  commit_lines.each do |commit_line, commit_sha|
115
- puts "* [#{commit_line}](#{git_url}/commit/#{commit_sha})"
115
+ puts "* [#{commit_line}](#{@git_hosting.commit_url(git_url, commit_sha)})"
116
116
  end
117
117
  puts
118
118
  end
@@ -1,5 +1,5 @@
1
1
  module SemVerComponents
2
2
 
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sem_ver_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-15 00:00:00.000000000 Z
11
+ date: 2021-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -62,6 +62,9 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - bin/sem_ver_git
65
+ - lib/sem_ver_components/git_hosting.rb
66
+ - lib/sem_ver_components/git_hostings/bitbucket.rb
67
+ - lib/sem_ver_components/git_hostings/github.rb
65
68
  - lib/sem_ver_components/local_git.rb
66
69
  - lib/sem_ver_components/output.rb
67
70
  - lib/sem_ver_components/outputs/info.rb