fastlane-plugin-changelog_generator 0.1.0 → 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: 67daa454054c49d43152b86f2738ef1e5d52ec91
4
- data.tar.gz: f8c16f08af744b4d7052c61ef56e7776929e6f55
3
+ metadata.gz: 741359874cb09cf98217125eb8fa4f170feba154
4
+ data.tar.gz: 1c2c405f51e39405a19c2af10e240ca85b264785
5
5
  SHA512:
6
- metadata.gz: 8e80c8bd71f77a33ef6e5b4441b3741c662877e11e1b910e0e4fc4c51bb18b8fbe55c983e180761754469921e6e734640a0211a578d3a15c4de777ea0a218675
7
- data.tar.gz: 68a5ed0387357f6bbd8a745e89007111e8362b55f433b6bcb327b636b7c129923dd20d5fdd75f0eb54b4b6d5de7aa2644a49d9f43e126f59c54705f2497ab172
6
+ metadata.gz: 3fa0a3bddd0ac73e747eca18d9d5005497eb360c0fcac1b6c9ed7b282e1bc13136a343275c23268660da4b7699cb06e394018e36fb1a48a38dbda1ec326126e5
7
+ data.tar.gz: e3b3c7e422bd8739bae4ee5c8d7bd11805fbd26efea912fda0f402d59e38e6c2ef708beee282bce2f44db23a5f6e8b4a81b8eeb1acee0673688f1e5649e885f9
@@ -2,12 +2,10 @@ module Fastlane
2
2
  module Actions
3
3
  class GenerateChangelogAction < Action
4
4
  def self.run(params)
5
- labels, pull_requests = other_action.fetch_github_labels(github_project: params[:github_project],
6
- base_branch: params[:base_branch],
7
- github_api_token: params[:github_api_token])
5
+ labels, pull_requests = Helper::ChangelogGeneratorFetcher.fetch_github_data(params, lane_context)
8
6
 
9
7
  tag_limit = params[:max_number_of_tags]
10
- tags = params[:tags] || other_action.git_tags(limit: tag_limit)
8
+ tags = params[:tags] || Helper::ChangelogGeneratorHelper.git_tags(tag_limit)
11
9
  releases = []
12
10
 
13
11
  # Unreleased section
@@ -8,9 +8,7 @@ module Fastlane
8
8
  tag_b = prompt_tag("Please enter second tag: ", [tag_a], true)
9
9
  end
10
10
 
11
- labels, pull_requests = other_action.fetch_github_labels(github_project: params[:github_project],
12
- base_branch: params[:base_branch],
13
- github_api_token: params[:github_api_token])
11
+ labels, pull_requests = Helper::ChangelogGeneratorFetcher.fetch_github_data(params, lane_context)
14
12
 
15
13
  release = Helper::ChangelogGeneratorRelease.new(labels, pull_requests, tag_b, tag_a)
16
14
  Helper::ChangelogGeneratorRender.new([release], labels, params).to_markdown
@@ -18,10 +16,16 @@ module Fastlane
18
16
 
19
17
  def self.prompt_tag(message = '', excluded_tags = [], allow_none = false)
20
18
  no_tag_text = 'No tag'
19
+ other_tag_text = 'Enter tag manually'
20
+ tag_limit = 10
21
21
 
22
- available_tags = other_action.git_tags(limit: 10)
22
+ available_tags = Helper::ChangelogGeneratorHelper.git_tags
23
23
  available_tags.reject! { |tag| excluded_tags.include?(tag) }
24
+ tags_count = available_tags.count
25
+
26
+ available_tags = available_tags.take(tag_limit)
24
27
  available_tags << no_tag_text if allow_none
28
+ available_tags << other_tag_text if tags_count > tag_limit
25
29
 
26
30
  if allow_none && available_tags.count == 1
27
31
  UI.important("Skiping second tag because there are no tags available.")
@@ -30,6 +34,7 @@ module Fastlane
30
34
 
31
35
  tag = UI.select(message, available_tags)
32
36
  tag = nil if tag == no_tag_text
37
+ tag = UI.input('Tag: ') if tag == other_tag_text
33
38
  tag
34
39
  end
35
40
 
@@ -3,11 +3,26 @@ require 'octokit'
3
3
  module Fastlane
4
4
  module Helper
5
5
  class ChangelogGeneratorFetcher
6
- def self.fetch_labels(project, base_branch, access_token)
7
- Actions.verify_gem!('octokit')
6
+ module SharedValues
7
+ GENERATE_CHANGELOG_GITHUB_LABELS = :GENERATE_CHANGELOG_GITHUB_LABELS
8
+ GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS = :GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS
9
+ end
8
10
 
11
+ def self.fetch_github_data(params, lane_context)
12
+ Actions.verify_gem!('octokit')
9
13
  Octokit.auto_paginate = true
10
14
 
15
+ labels = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS]
16
+ pull_requests = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS]
17
+ if labels && pull_requests
18
+ UI.important "Skipping API call because labels & pull requests are cached"
19
+ return labels, pull_requests
20
+ end
21
+
22
+ project = params[:github_project]
23
+ base_branch = params[:base_branch]
24
+ access_token = params[:github_api_token]
25
+
11
26
  issues_map = {}
12
27
  Octokit.issues(project, state: 'closed', access_token: access_token).each do |issue|
13
28
  issues_map[issue.number] = issue
@@ -32,6 +47,9 @@ module Fastlane
32
47
  pr.label_ids = issues_map[pr.number].labels.map(&:id)
33
48
  end
34
49
 
50
+ lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS] = labels
51
+ lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS] = pull_requests
52
+
35
53
  return labels, pull_requests
36
54
  end
37
55
  end
@@ -1,11 +1,10 @@
1
1
  module Fastlane
2
2
  module Helper
3
3
  class ChangelogGeneratorHelper
4
- # class methods that you define here become available in your action
5
- # as `Helper::ChangelogGeneratorHelper.your_method`
6
- #
7
- def self.show_message
8
- UI.message("Hello from the changelog_generator plugin helper!")
4
+ def self.git_tags(limit = nil)
5
+ tags = `git tag --sort=taggerdate`.split("\n").reverse
6
+ tags = tags.take(limit) if limit
7
+ tags
9
8
  end
10
9
  end
11
10
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module ChangelogGenerator
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-changelog_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Saragoca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -117,10 +117,8 @@ files:
117
117
  - LICENSE
118
118
  - README.md
119
119
  - lib/fastlane/plugin/changelog_generator.rb
120
- - lib/fastlane/plugin/changelog_generator/actions/fetch_github_labels_action.rb
121
120
  - lib/fastlane/plugin/changelog_generator/actions/generate_changelog_action.rb
122
121
  - lib/fastlane/plugin/changelog_generator/actions/generate_release_changelog_action.rb
123
- - lib/fastlane/plugin/changelog_generator/actions/git_tags_action.rb
124
122
  - lib/fastlane/plugin/changelog_generator/helper/changelog_generator_fetcher.rb
125
123
  - lib/fastlane/plugin/changelog_generator/helper/changelog_generator_helper.rb
126
124
  - lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb
@@ -1,70 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- class FetchGithubLabelsAction < Action
4
- module SharedValues
5
- GENERATE_CHANGELOG_GITHUB_LABELS = :GENERATE_CHANGELOG_GITHUB_LABELS
6
- GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS = :GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS
7
- end
8
-
9
- def self.run(params)
10
- Actions.verify_gem!('octokit')
11
-
12
- labels = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS]
13
- pull_requests = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS]
14
- if labels && pull_requests
15
- UI.important "Skipping API call because labels & pull requests are cached"
16
- return labels, pull_requests
17
- end
18
-
19
- api_token = params[:github_api_token]
20
- base_branch = params[:base_branch]
21
- project = params[:github_project]
22
-
23
- labels, pull_requests = Helper::ChangelogGeneratorFetcher.fetch_labels(project,
24
- base_branch,
25
- api_token)
26
- lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS] = labels
27
- lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS] = pull_requests
28
- return labels, pull_requests
29
- end
30
-
31
- def output
32
- [
33
- ['GENERATE_CHANGELOG_GITHUB_LABELS', 'Fetched GitHub labels'],
34
- ['GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS', 'Fetched GitHub pull requests']
35
- ]
36
- end
37
-
38
- def self.description
39
- "Fetches GitHub for labels & merged pull requests"
40
- end
41
-
42
- def self.authors
43
- ["Fernando Saragoca"]
44
- end
45
-
46
- def self.return_value
47
- "A tuple with an array of labels & an array of pull requests"
48
- end
49
-
50
- def self.available_options
51
- [
52
- FastlaneCore::ConfigItem.new(key: :github_project,
53
- env_name: 'GENERATE_CHANGELOG_GITHUB_PROJECT',
54
- description: 'GitHub project name, including organization'),
55
- FastlaneCore::ConfigItem.new(key: :github_api_token,
56
- env_name: 'GENERATE_CHANGELOG_GITHUB_API_TOKEN',
57
- description: 'API token to access GitHub API',
58
- default_value: ENV["GITHUB_API_TOKEN"]),
59
- FastlaneCore::ConfigItem.new(key: :base_branch,
60
- env_name: 'GENERATE_CHANGELOG_BASE_BRANCH',
61
- description: 'Base branch for pull requests')
62
- ]
63
- end
64
-
65
- def self.is_supported?(platform)
66
- true
67
- end
68
- end
69
- end
70
- end
@@ -1,37 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- class GitTagsAction < Action
4
- def self.run(params)
5
- tags = `git tag --sort=taggerdate`.split("\n").reverse
6
- tags = tags.take(params[:limit]) if params[:limit]
7
- tags
8
- end
9
-
10
- def self.description
11
- "Git tags sorted by taggerdate"
12
- end
13
-
14
- def self.authors
15
- ["Fernando Saragoca"]
16
- end
17
-
18
- def self.return_value
19
- "Array of git tags sorted by taggerdate"
20
- end
21
-
22
- def self.available_options
23
- [
24
- FastlaneCore::ConfigItem.new(key: :limit,
25
- env_name: 'GIT_TAGS_LIMIT',
26
- description: 'Limit number of tags to return',
27
- is_string: false,
28
- optional: true)
29
- ]
30
- end
31
-
32
- def self.is_supported?(platform)
33
- true
34
- end
35
- end
36
- end
37
- end