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
AliSoftware committed Mar 24, 2022
1 parent 9eb7407 commit 9c557da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastlane/lanes/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
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 All @@ -261,7 +261,7 @@
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 9c557da

Please sign in to comment.