fastlane-plugin-ci_changelog 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b94166581e3e8e438e50791da2fb63abf504095c777e519bef66eea2b288dd0f
4
- data.tar.gz: 6065c772d518aaea3a7b472f2407bcf779bcf7f2e71fddb00d4b0ac08cd0d9c6
3
+ metadata.gz: b1282307e44fff5f87df59f1ecd02151d45570a0d9607a1688873ee2e65ef99e
4
+ data.tar.gz: 3bc5f6a4bab39255aea3545b351711f22fee754958c3b62f2139535d7d6b63a8
5
5
  SHA512:
6
- metadata.gz: 59b02f3c05ab4a4fb081d099a06c8ac2f68e919db4cb1575663f6d4e69e605c7ead4e1871a926befd28dfbbd3127b51da437a49fa4c930e3be37d1dbaddb2a75
7
- data.tar.gz: a20bd90307e96f7f215aa2fd0a9ea5a20ed20e95017e952d682fe896f8d055d8337fd8dc8bd8863e99e2e5a2b9559be3f84dd0178cd965e4d885f7d462c4093f
6
+ metadata.gz: 511c98128befa5594c56d350955b520d3b2e2cc29b3a67324728ab66198a43313046b78caafe9af43a8a9a3283b84fb8b3e187a4feb90c6241f9b9fff69c26a8
7
+ data.tar.gz: efb0cf35c098c3959a3694e88156ee331ce57ace9a7887ff8427b4ce291980f9f2940bae5893222e8f84cc3e4b0840cdf26631a0efccf1201349efc742672d64
@@ -3,11 +3,6 @@ require 'json'
3
3
  module Fastlane
4
4
  module Helper
5
5
  class CiChangelogHelper
6
- def self.git_commits(last_success_commit)
7
- git_logs = `git log --pretty="format:%s - %cn [%ci]" #{last_success_commit}..HEAD`.strip.gsub(' +0800', '')
8
- git_logs.split("\n")
9
- end
10
-
11
6
  def self.dump_jenkins_commits(body, branch)
12
7
  json = JSON.parse(body)
13
8
  UI.verbose("- API Result: #{json['result']}")
@@ -35,8 +30,11 @@ module Fastlane
35
30
  project_id = ENV['CI_PROJECT_ID']
36
31
  from, to = fetch_gitlab_compare_commit(endpoint, private_token, project_id)
37
32
  return [] unless from && to
38
-
39
- fetch_gitlab_commits(endpoint, private_token, project_id, from, to)
33
+ if from == to
34
+ fetch_gitlab_single_commit(endpoint, private_token, project_id, from)
35
+ else
36
+ fetch_gitlab_commits(endpoint, private_token, project_id, from, to)
37
+ end
40
38
  end
41
39
 
42
40
  def self.fetch_gitlab_compare_commit(endpoint, private_token, project_id)
@@ -52,18 +50,22 @@ module Fastlane
52
50
  .get(jobs_url)
53
51
 
54
52
  jobs = res.parse.select { |job| job['name'] == job_name }
53
+ UI.verbose("Matched jobs #{job_name}: #{jobs.size}")
55
54
 
56
- commits = []
57
- jobs.each_with_index do |job, i|
58
- commit = job['pipeline']['sha']
59
- case job['status']
60
- when 'running'
61
- to_commit = commit
62
- when 'success'
63
- if to_commit.nil?
55
+ if jobs.size == 1
56
+ to_commit = from_commit = jobs[0]['pipeline']['sha']
57
+ else
58
+ jobs.each_with_index do |job, i|
59
+ commit = job['pipeline']['sha']
60
+ case job['status']
61
+ when 'running'
64
62
  to_commit = commit
65
- elsif to_commit && from_commit.nil?
66
- from_commit = commit
63
+ when 'success'
64
+ if to_commit.nil?
65
+ to_commit = commit
66
+ elsif to_commit && from_commit.nil?
67
+ from_commit = commit
68
+ end
67
69
  end
68
70
  end
69
71
  end
@@ -86,6 +88,29 @@ module Fastlane
86
88
  end
87
89
  end
88
90
 
91
+ def self.fetch_gitlab_single_commit(endpoint, private_token, project_id, sha)
92
+ commit_url = "#{endpoint}/projects/#{project_id}/repository/commits/#{sha}"
93
+ UI.verbose("Fetching single commit url #{commit_url}")
94
+ res = HTTP.follow
95
+ .headers('PRIVATE-TOKEN' => private_token)
96
+ .get(commit_url)
97
+
98
+ commits = []
99
+ if res.code == 200
100
+ commit = res.parse
101
+ commits << {
102
+ id: commit['id'],
103
+ date: commit['created_at'],
104
+ title: commit['title'].strip,
105
+ message: commit['title'].strip,
106
+ author: commit['author_name'].strip,
107
+ email: commit['author_email'].strip
108
+ }
109
+ end
110
+
111
+ commits
112
+ end
113
+
89
114
  def self.fetch_gitlab_commits(endpoint, private_token, project_id, from, to)
90
115
  compare_url = "#{endpoint}/projects/#{project_id}/repository/compare"
91
116
  params = {
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module CiChangelog
3
- VERSION = '0.6.0'.freeze
3
+ VERSION = '0.6.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ci_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http