Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toml): Convert warnings that licence and readme files do not exist into errors #13921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heisen-li
Copy link
Contributor

What does this PR try to resolve?

In this PR:

  • Changed the warning to a hard error and modified the associated test function;
  • Removed what should have been a redundant test function:publish::publish_with_missing_readme
  • Since cargo publish is preceded by the execution of cargo package, the error message in the test function bad_license_file needs to be modified.

issue: #13629 (comment).

Additional information

It seems that this is not enough, the current situation is that cargo package warns if package.readme is an empty string or the wrong file location, but if I cancel package.readme, no warning is generated.

I'm wondering if I should judge package.readme&licence when executing cargo package and return an error if it doesn't exist?

As this has not been done before, your advice is sought.

@rustbot
Copy link
Collaborator

rustbot commented May 16, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added Command-package S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 16, 2024
@weihanglo
Copy link
Member

@bors try

@bors
Copy link
Collaborator

bors commented May 29, 2024

⌛ Trying commit 5c35e29 with merge 2faa4a0...

bors added a commit that referenced this pull request May 29, 2024
fix(toml): Convert warnings that `licence` and `readme` files do not exist into errors

### What does this PR try to resolve?

In this PR:
- Changed the warning to a hard error and modified the associated test function;
- Removed what should have been a redundant test function:`publish::publish_with_missing_readme`;
- Since `cargo publish` is preceded by the execution of `cargo package`, the error message in the test `function bad_license_file` needs to be modified.

issue: #13629 (comment).

### Additional information

It seems that this is not enough, the current situation is that `cargo package` warns if `package.readme` is an empty string or the wrong file location, but if I cancel `package.readme`, no warning is generated.

I'm wondering if I should judge `package.readme&licence` when executing `cargo package` and return an error if it doesn't exist?

As this has not been done before, your advice is sought.
@bors
Copy link
Collaborator

bors commented May 29, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 29, 2024
@weihanglo
Copy link
Member

@bors try

bors added a commit that referenced this pull request May 29, 2024
fix(toml): Convert warnings that `licence` and `readme` files do not exist into errors

### What does this PR try to resolve?

In this PR:
- Changed the warning to a hard error and modified the associated test function;
- Removed what should have been a redundant test function:`publish::publish_with_missing_readme`;
- Since `cargo publish` is preceded by the execution of `cargo package`, the error message in the test `function bad_license_file` needs to be modified.

issue: #13629 (comment).

### Additional information

It seems that this is not enough, the current situation is that `cargo package` warns if `package.readme` is an empty string or the wrong file location, but if I cancel `package.readme`, no warning is generated.

I'm wondering if I should judge `package.readme&licence` when executing `cargo package` and return an error if it doesn't exist?

As this has not been done before, your advice is sought.
@bors
Copy link
Collaborator

bors commented May 29, 2024

⌛ Trying commit 5c35e29 with merge 8c704a8...

@bors
Copy link
Collaborator

bors commented May 29, 2024

☀️ Try build successful - checks-actions
Build commit: 8c704a8 (8c704a85981cad6eaf25a0e12a6a290f6d234c5c)

license || license_file,
documentation || homepage || repository
);
lacking!(description, documentation || homepage || repository);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did license || license_file part get removed? It is still required to have license specified.

let rel_msg = if path.is_absolute() {
"".to_string()
} else {
format!(" (relative to `{}`)", pkg.root().display())
};
ws.gctx().shell().warn(&format!(

let msg = format!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo checks only two fields, so it is fine just returning an Err here . That would make the code easier to reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard error, even for empty string

Should we add test checking empty string like license-file = "" or readme = "" will fail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-package S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants