Previously, we assumed that if 'gh' and 'jq' could not find any version information from a GitHub plugin repo then the shell command would exit with a non-zero exit code.
In practice, we have found (with the 'loco-translate' plugin) that the shell exec writes some text to stderr and exit with status 0. However, it returns the string '.\n'.
In this commit we check for that string that is returned by 'jq' and if that is the result of the shell exec we return an empty string, indicating that the repo had no tags.
This is important because when we mirror an entirely new plugin, we do so from a completely empty repository.
Original error
==> Fetching all GitHub plugin repositories in the library...
==> Found 786 plugins in the library
-----------------------------------------------------------------------
==> Checking status of loco-translate...
==> Querying GitHub for latest version ...
gh: Git Repository is empty. (HTTP 409)
==> Querying api.wordpress.org for latest version ...
/opt/hostedtoolcache/Ruby/2.7.2/x64/lib/ruby/2.7.0/rubygems/version.rb:2[15](https://github.com/dxw-wordpress-plugins/mirror-gitlab-plugins/actions/runs/10144439030/job/28047924851#step:7:16):in `initialize': Malformed version number string . (ArgumentError)
from /opt/hostedtoolcache/Ruby/2.7.2/x64/lib/ruby/2.7.0/rubygems/version.rb:206:in `new'
from /opt/hostedtoolcache/Ruby/2.7.2/x64/lib/ruby/2.7.0/rubygems/version.rb:206:in `new'
from ./mirror-wordpress-plugins:78:in `repos_need_updating?'
from ./mirror-wordpress-plugins:3[20](https://github.com/dxw-wordpress-plugins/mirror-gitlab-plugins/actions/runs/10144439030/job/28047924851#step:7:21):in `block in update'
from ./mirror-wordpress-plugins:301:in `each'
from ./mirror-wordpress-plugins:301:in `update'
from ./mirror-wordpress-plugins:403:in `<main>'
==> loco-translate is v2.6.11 on WordPress and v. on GitHub
Make sure that all DRY_RUN_... variables are true and all FORCE_... variables are false
Create a new GitHub PAT token or use the one in 1Password under GovPress tools service account ... mirror-gitlab-plugins and add it to the appropriate variable in your .env file
Optionally, comment out lines 132-134 in the cleanup method in mirror-wordpress-plugins so that you can check tags and so on in the "mirrored" repos
From the main branch run ./mirror-wordpress-plugins --dry-run and check that loco-translate fails to mirror with an error message
Checkout this branch and run the script again. Check that loco-translate is mirrored
If you commented out lines 132-134 go into the new loco-translate directory and check there is a Git commit and a Git tag
Previously, we assumed that if 'gh' and 'jq' could not find any version information from a GitHub plugin repo then the shell command would exit with a non-zero exit code.
In practice, we have found (with the 'loco-translate' plugin) that the shell exec writes some text to stderr and exit with status 0. However, it returns the string '.\n'.
In this commit we check for that string that is returned by 'jq' and if that is the result of the shell exec we return an empty string, indicating that the repo had no tags.
This is important because when we mirror an entirely new plugin, we do so from a completely empty repository.
Original error
https://github.com/dxw-wordpress-plugins/mirror-gitlab-plugins/actions/runs/10144439030/job/28047924851
Testing
.env.example
to.env
DRY_RUN_...
variables aretrue
and allFORCE_...
variables arefalse
GovPress tools service account
...mirror-gitlab-plugins
and add it to the appropriate variable in your.env
filecleanup
method inmirror-wordpress-plugins
so that you can check tags and so on in the "mirrored" reposmain
branch run./mirror-wordpress-plugins --dry-run
and check thatloco-translate
fails to mirror with an error messageloco-translate
is mirroredloco-translate
directory and check there is a Git commit and a Git tag