Skip to content

Commit

Permalink
Change git asset URL for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyfae committed Jan 29, 2022
1 parent b3f1356 commit 75362dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/API/v1/CreateRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function register(): void
return $this->stripUnsafeCharacters(sanitize_text_field($param));
}
],
'file_url' => [
'git_asset_url' => [
'required' => false,
'sanitize_callback' => function ($param, $request, $key) {
return esc_url_raw($param);
Expand Down
6 changes: 3 additions & 3 deletions src/Actions/CreateAndPublishRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function execute(array $args): Release
throw new \InvalidArgumentException('Missing required file_name argument.', 400);
}

if (! empty($args['file_url'])) {
if (! empty($args['git_asset_url'])) {
$preparedFile = $this->releaseFileProcessor->executeFromGitAsset(
$args['file_url'],
$args['git_asset_url'],
$args['file_name']
);
} elseif (! empty($_FILES['file_zip'])) {
Expand All @@ -77,7 +77,7 @@ public function execute(array $args): Release
} else {
throw new \InvalidArgumentException(sprintf(
'You must provide one of the following parameters: %s',
json_encode(['file_url', 'file_zip', 'file_attachment_id', 'file_path'])
json_encode(['git_asset_url', 'file_zip', 'file_attachment_id', 'file_path'])
), 400);
}

Expand Down
16 changes: 8 additions & 8 deletions src/CliCommands/PublishRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function __invoke(array $args, array $assocArgs): void
\WP_CLI::confirm(__('Is this asset correct?', 'edd-sl-releases'));

$releaseArgs = [
'product_id' => $product->ID,
'version' => sanitize_text_field($release['tag_name']), // could also use 'name'
'file_url' => $asset['url'],
'file_name' => $asset['name'],
'changelog' => wp_kses_post($release['body']),
'requirements' => null, // @todo
'pre_release' => ! empty($release['prerelease']) ? 1 : 0,
'released_at' => ! empty($release['published_at'])
'product_id' => $product->ID,
'version' => sanitize_text_field($release['tag_name']), // could also use 'name'
'git_asset_url' => $asset['url'],
'file_name' => $asset['name'],
'changelog' => wp_kses_post($release['body']),
'requirements' => null, // @todo
'pre_release' => ! empty($release['prerelease']) ? 1 : 0,
'released_at' => ! empty($release['published_at'])
? date('Y-m-d H:i:s', strtotime($release['published_at']))
: gmdate('Y-m-d H:i:s'),
];
Expand Down
10 changes: 5 additions & 5 deletions tests/API/CreateReleaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function test_unauthenticated_request_returns_401()
* @covers \EddSlReleases\API\v1\CreateRelease::restPermissionCheck
* @covers \EddSlReleases\API\v1\CreateRelease::handle
*/
public function test_valid_args_with_file_url_creates_new_release()
public function test_valid_args_with_git_asset_url_creates_new_release()
{
wp_set_current_user(1);

Expand All @@ -77,10 +77,10 @@ public function test_valid_args_with_file_url_creates_new_release()
->andReturn(new PreparedReleaseFile('/var/www/mysite.com/file.zip', 1));

$response = $this->makeRestRequest($this->getApiEndpoint(), [
'version' => '1.0',
'file_url' => 'https://sample-url.com',
'file_name' => 'sample-file.zip',
'requirements' => [
'version' => '1.0',
'git_asset_url' => 'https://sample-url.com',
'file_name' => 'sample-file.zip',
'requirements' => [
'php' => '7.4',
]
]);
Expand Down

0 comments on commit 75362dd

Please sign in to comment.