fastlane-plugin-csv_translation 0.4.0 β†’ 0.4.1

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: d0f16b7ee0ca379dd5ea0519771ff45f609c567715fc10e6245175a9dde17571
4
- data.tar.gz: 4735dd08f4a574bf92d820937a51131a7ea73525801e507ae67bf20f37e01b48
3
+ metadata.gz: 7189ea70602d3f9110b9275ccff1d796c1ada3e1169217a4c6ed58df5d73ac18
4
+ data.tar.gz: d459fb0ed36b20e1fb453dd91bcab49d3af60e345d7027326c02d4b0e68a50f1
5
5
  SHA512:
6
- metadata.gz: 82be092d741b44d89dbbc1bf0b476575f4a0decb18c3f12583c87904c0de618f18a3d61af94a033099e516fee67ef55d9e06945446c1ed62adfba86acf122e65
7
- data.tar.gz: 423d5e8a753a5aeb1ccd4a80ecab0e71ed98f2a9b45696c69ab43bf530ff619ffc973bcfe06e24df0a58151efb0e7652f715970a1a15bc812591ffad3ce20f79
6
+ metadata.gz: bb5b1e92b389a06f1d0f7a88483092e82489efe6450fec63b42bbe11746f653619b092340bdb6e8dffc67f395ec34fa7ba7918d22aa4ac9c812b0034465662dd
7
+ data.tar.gz: 2230a17886dc5485dea6aef9858513d3ec8906aa0d6b41180055f104b91c153bfcb2c6ebb3d68d8947e76da932b28774788ea222492b4dfb06365aecfbabdb9b
data/README.md CHANGED
@@ -55,7 +55,7 @@ get_csv_translation_requests(
55
55
  Add a new translation request entry inside the CSV file. It will append a new row in CSV file and then git commit the CSV file changes.
56
56
 
57
57
  ``` ruby
58
- example_csv_payload = {Ticket: "PRJ-3030", Timeline: "30 April"}
58
+ example_csv_payload = { "Ticket" => "PRJ-3030", "Timeline" => "30 April" }
59
59
 
60
60
  create_csv_translation_request(
61
61
  repository_name: "crazymanish/example-csv-repo", # Specify the CSV git file repo
@@ -65,7 +65,7 @@ create_csv_translation_request(
65
65
  ```
66
66
 
67
67
  ### πŸ”rebase_csv_translation_request
68
- Rebase a translation request entry inside the CSV file. It will append a new row top of target branch in CSV file and then git commit the CSV file changes.
68
+ Rebase a translation request entry inside the CSV file. It will append a new row top of target branch in CSV file and then git commit the CSV file changes. Very useful in case of resolving conflicts.
69
69
 
70
70
  ``` ruby
71
71
  rebase_csv_translation_request(
@@ -20,14 +20,7 @@ module Fastlane
20
20
  csv_payload = params[:payload]
21
21
 
22
22
  # add missing newline if not present, at the end of the file
23
- File.open(csv_file_path, "r+") do |csv|
24
- csv.seek(-1, 2)
25
-
26
- if csv.read(1) != "\n"
27
- csv.write("\n")
28
- csv.seek(0)
29
- end
30
- end
23
+ Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
31
24
 
32
25
  # adding new entry into csv file
33
26
  require 'csv'
@@ -31,32 +31,15 @@ module Fastlane
31
31
  sh("git fetch --all")
32
32
  sh("git checkout #{params[:branch_name]} -- #{params[:file_path]}")
33
33
 
34
- # Step2: Commit csv file so rebase can be performed
35
- git_message = "Rebase translation request: identifier:\n#{csv_row_identifier}"
36
- GitCommitAction.run(path: ".", message: git_message)
37
-
38
- # Step3: Perfoms rebasing, take all changes from target branch
39
- sh("git rebase -X theirs " + params[:branch_name])
40
-
41
- # Step4: Add missing newline if not present, at the end of the file
42
- Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
43
-
44
- # Step5: Append back feature branch translation_requests
45
- all_translation_requests = CSV.table(csv_file_path, headers: true)
46
- all_translation_requests.delete_if { |row| row.map { |value| value.to_s }.join("").include?(csv_row_identifier) }
47
-
48
- headers = CSV.open(csv_file_path, &:readline)
49
- CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
50
- all_translation_requests.each { |translation_request| csv << translation_request }
51
- feature_branch_translation_requests.each { |translation_request| csv << translation_request }
34
+ # Validate: Do we really need to perfoem `rebase` ?
35
+ repo_status = Actions::sh("git status --porcelain")
36
+ repo_clean = repo_status.empty?
37
+
38
+ if repo_clean
39
+ UI.important("Rebase is not required, CSV file is up to date! πŸ’ͺ")
40
+ else
41
+ git_commit_info = self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
52
42
  end
53
-
54
- # Step6: Commit and push to remote
55
- GitCommitAction.run(path: ".", message: git_message)
56
- PushToGitRemoteAction.run(remote: "origin", force: true)
57
-
58
- git_commit_info = Actions.last_git_commit_dict
59
- UI.success("Successfully #{git_message} πŸš€")
60
43
  end
61
44
 
62
45
  # building deleted translation request info
@@ -68,6 +51,37 @@ module Fastlane
68
51
  return rebase_translation_request_info
69
52
  end
70
53
 
54
+ def self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
55
+ csv_row_identifier = params[:identifier]
56
+
57
+ # Step2: Commit csv file so rebase can be performed
58
+ git_message = "Rebase translation request: identifier:\n#{csv_row_identifier}"
59
+ GitCommitAction.run(path: ".", message: git_message)
60
+
61
+ # Step3: Perfoms rebasing, take all changes from target branch
62
+ sh("git rebase -X theirs " + params[:branch_name])
63
+
64
+ # Step4: Add missing newline if not present, at the end of the file
65
+ Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
66
+
67
+ # Step5: Append back feature branch translation_requests
68
+ all_translation_requests = CSV.table(csv_file_path, headers: true)
69
+ all_translation_requests.delete_if { |row| row.map { |value| value.to_s }.join("").include?(csv_row_identifier) }
70
+
71
+ headers = CSV.open(csv_file_path, &:readline)
72
+ CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
73
+ all_translation_requests.each { |translation_request| csv << translation_request }
74
+ feature_branch_translation_requests.each { |translation_request| csv << translation_request }
75
+ end
76
+
77
+ # Step6: Commit and push to remote
78
+ GitCommitAction.run(path: ".", message: git_message)
79
+ PushToGitRemoteAction.run(remote: "origin", force: true)
80
+
81
+ UI.success("Successfully #{git_message} πŸš€")
82
+ Actions.last_git_commit_dict
83
+ end
84
+
71
85
  def self.description
72
86
  "Rebase a translation request based on identifier value."
73
87
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module CsvTranslation
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-csv_translation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manish Rathi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry