Skip to content

Commit 0eb3da4

Browse files
committed
Use common function to get project root and name, to also help with unit testing
1 parent 58c839c commit 0eb3da4

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ module GitHelper
1818
# @param [Bool] include_metadata If true (the default), includes the `fastlane/download_metadata.swift` file and the `.pot` file (which typically contains an entry or release notes for the new version)
1919
#
2020
def self.commit_version_bump(include_deliverfile: true, include_metadata: true)
21-
files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')]
21+
files_list = [File.join(get_project_root(), 'config', '.')]
2222
files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile
2323
if include_metadata
2424
files_list.append File.join('fastlane', 'download_metadata.swift')
25-
files_list.append File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'Resources', ENV['APP_STORE_STRINGS_FILE_NAME'])
25+
files_list.append File.join(get_project_root(), get_project_name(), 'Resources', get_from_env!(key: 'APP_STORE_STRINGS_FILE_NAME'))
2626
end
2727

2828
Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true)
@@ -54,7 +54,7 @@ def self.localize_project
5454
# in the release-toolkit instead, and move this code away from `ios_git_helper`.
5555
#
5656
def self.update_metadata
57-
Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/update-translations.rb")
57+
Action.sh("cd #{get_project_root()} && ./Scripts/update-translations.rb")
5858

5959
Fastlane::Helper::GitHelper.commit(message: 'Update translations', files: strings_files, push: false)
6060

@@ -64,12 +64,20 @@ def self.update_metadata
6464
end
6565

6666
def self.strings_files
67-
project_root = get_from_env!(key: 'PROJECT_ROOT_FOLDER')
68-
project_name = get_from_env!(key: 'PROJECT_NAME')
67+
project_root = get_project_root()
68+
project_name = get_project_name()
6969

7070
Dir.glob(File.join(project_root, project_name, '**', '*.strings'))
7171
end
7272

73+
def self.get_project_root
74+
get_from_env!(key: 'PROJECT_ROOT_FOLDER')
75+
end
76+
77+
def self.get_project_name
78+
get_from_env!(key: 'PROJECT_NAME')
79+
end
80+
7381
def self.get_from_env!(key:)
7482
ENV.fetch(key) do
7583
UI.user_error! "Could not find value for \"#{key}\" in environment."

0 commit comments

Comments
 (0)