Skip to content

Commit

Permalink
Use absolute paths when committing Fastlane metadata
Browse files Browse the repository at this point in the history
The previous version used `Dir.glob('**/*.txt', base:
metadata_directory)`, but that didn't work for two reasons.

First, even if we use `base:`, the paths returned by `glob` are still
relative. From the docs:

> The optional base keyword argument specifies the base directory for
> interpreting relative pathnames instead of the current working
> directory. As the results are not prefixed with the base directory name
> in this case, you will need to prepend the base directory name if you
> want real paths.

See https://ruby-doc.org/core-2.7.4/Dir.html#method-c-glob .

Second, `Dir.glob` returns the files that match the given pattern, but
that excludes _deleted_ files. If a file is not there anymore, it can't
match the given pattern. This would have made the commit incomplete.

We could argue whether our code should delete the existing translations
when it doesn't find new ones. Even if we concluded that behavior is not
desirable, we'd still need to account for it locally until we update it
in the release toolkit. Otherwise, our local copies would remain dirty
after downloading the release notes metadata if no new ones are
available.
  • Loading branch information
mokagio committed Mar 24, 2022
1 parent 81e5969 commit 2e3dbf0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ platform :ios do
FileUtils.cp(release_notes_source, File.join(metadata_directory, 'en-US', 'release_notes.txt'))

git_commit(
path: Dir.glob('**/*.txt', base: metadata_directory),
path: File.join(metadata_directory, '**', '*.txt'),
message: 'Update WordPress metadata translations',
allow_nothing_to_commit: true
)
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Jetpack-Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ lane :download_jetpack_localized_app_store_metadata do
FileUtils.cp(release_notes_source, File.join(metadata_directory, 'en-US', 'release_notes.txt'))

git_commit(
path: Dir.glob('**/*.txt', base: metadata_directory),
path: File.join(metadata_directory, '**', '*.txt'),
message: 'Update Jetpack metadata translations',
allow_nothing_to_commit: true
)
Expand Down

0 comments on commit 2e3dbf0

Please sign in to comment.