fastlane-plugin-approved 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07f6872c458a5f49b5a1c7a835f9909370504f5e7f3a32d0a9329e72f16ae116
4
- data.tar.gz: 6a00e2d1f00fb2f99de85d62f03a4dab7de41652047c8940a63ea76f4c8ed9c0
3
+ metadata.gz: 8470e76d8e4b1dd64d18ed7cb374b5a684a1d61d1334112ba5472ebce240b32b
4
+ data.tar.gz: fc0b7a00aa459f10016aa0a6699a3ed95744a2353b867681eedbc6f328ae04ee
5
5
  SHA512:
6
- metadata.gz: 8222aa92d8868e3566ed048c584e65c82c6e990bde2bb0d816282f604bafe8c5b78102cb5c8b1d02740753f39b9d38e635575fe3d678d6b980eb9ccba5ffcbbc
7
- data.tar.gz: d42c4825dff3154cd14b6532502fa28d5d45930c129c7ddb438e49693936d7f8d5dafe34a5db8a924c44cd99d13e8af00abffc02462c20ab91a86b16fdd534d1
6
+ metadata.gz: a069ed2c4a51716c4533fe50a01ec6bd5dbecb5327bd3acc7c8d7c846c392fdb18718bdfa9b5cc770365c068a5b2862a2dc6d340cc3193b42ba2dff8bc96ec99
7
+ data.tar.gz: '00783349ed6141ea2051ef728293b22992c7ef46193d8b63763b14a226888791b621a06e10d30552b095c1f09cccdfef0157afc7c214ce3a1584e24770718120'
@@ -6,15 +6,28 @@ module Fastlane
6
6
  class ApprovedAction < Action
7
7
  def self.run(params)
8
8
  require 'pathname'
9
+ require 'fileutils'
10
+
9
11
  repo_path = Dir.getwd
10
12
  repo_pathname = Pathname.new(repo_path)
11
13
  other_action.approved_precheck
12
14
 
13
15
  head = Actions.sh("git -C #{repo_path} rev-parse HEAD").strip
14
16
 
15
- approved_file_path = params[:approval_file_path]
16
- approved_file_absolute_path = approved_file_path.replace approved_file_path.sub("#{repo_pathname}", "./")
17
- puts " -- updated = #{approved_file_absolute_path}".yellow
17
+ approved_folder_path = params[:approval_folder]
18
+ approved_folder_absolute_path = approved_folder_path.replace approved_folder_path.sub("#{repo_pathname}", "./")
19
+ # Prepare Approval Folder
20
+ FileUtils.mkdir_p approved_folder_absolute_path
21
+
22
+ existing_files = Dir[File.join(approved_folder_absolute_path, "*")]
23
+ existing_files.each { |file|
24
+ puts " -- remove old approval file > #{file}".yellow
25
+ File.delete(file)
26
+ }
27
+
28
+ approved_file_absolute_path = File.join(approved_folder_absolute_path, head)
29
+
30
+ puts " -- create approval file > #{approved_file_absolute_path}".yellow
18
31
  File.expand_path(File.join(repo_pathname, approved_file_absolute_path))
19
32
 
20
33
  File.open(approved_file_absolute_path, "w") { |f| f.write "#{head}" }
@@ -24,6 +37,7 @@ module Fastlane
24
37
  else
25
38
  # then create a commit with a message
26
39
  Actions.sh("git -C #{repo_path} add #{approved_file_absolute_path}")
40
+ existing_files.each { |file| Actions.sh("git -C #{repo_path} rm #{file}") }
27
41
  begin
28
42
  commit_message = "Approved commit #{head}"
29
43
  Actions.sh("git -C #{repo_path} commit -m '#{commit_message}'")
@@ -54,9 +68,9 @@ module Fastlane
54
68
 
55
69
  def self.available_options
56
70
  [
57
- FastlaneCore::ConfigItem.new(key: :approval_file_path,
58
- env_name: "APPROVED_FILE_PATH",
59
- description: "Path to approval file",
71
+ FastlaneCore::ConfigItem.new(key: :approval_folder,
72
+ env_name: "APPROVED_FOLDER",
73
+ description: "Folder to store approval file",
60
74
  optional: true,
61
75
  type: String,
62
76
  default_value: ".approved"),
@@ -10,9 +10,11 @@ module Fastlane
10
10
  UI.message("Performing Approved Pre-check!")
11
11
  git_dirty_files = Actions.sh("git -C #{repo_path} diff --name-only HEAD").split("\n") + Actions.sh("git -C #{repo_path} ls-files --other --exclude-standard").split("\n")
12
12
 
13
- approved_file_path = params[:approval_file_path]
14
- approved_file_name = File.basename(approved_file_path)
15
- git_dirty_files.delete(approved_file_name)
13
+ approved_folder_path = params[:approval_folder]
14
+ approved_folder_name = File.basename(approved_folder_path)
15
+ git_dirty_files.delete_if {|path|
16
+ path.start_with?(approved_folder_name)
17
+ }
16
18
 
17
19
  unless git_dirty_files.empty?
18
20
  error = [
@@ -44,10 +46,10 @@ module Fastlane
44
46
 
45
47
  def self.available_options
46
48
  [
47
- FastlaneCore::ConfigItem.new(key: :approval_file_path,
48
- env_name: "APPROVED_FILE_PATH",
49
- description: "Path to aproval file",
50
- optional: false,
49
+ FastlaneCore::ConfigItem.new(key: :approval_folder,
50
+ env_name: "APPROVED_FOLDER",
51
+ description: "Folder to store approval file",
52
+ optional: true,
51
53
  type: String,
52
54
  default_value: ".approved")
53
55
  ]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Approved
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-approved
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chalermpong Satayavibul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-29 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler