Page MenuHomePhabricator

[scripts] Clean up `rust_pre_commit.sh` using ShellCheck
ClosedPublic

Authored by abosh on Aug 2 2022, 9:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 27, 9:05 AM
Unknown Object (File)
Fri, Sep 27, 9:05 AM
Unknown Object (File)
Fri, Sep 27, 9:05 AM
Unknown Object (File)
Fri, Sep 27, 9:05 AM
Unknown Object (File)
Wed, Sep 11, 2:01 AM
Unknown Object (File)
Wed, Sep 11, 2:01 AM
Unknown Object (File)
Wed, Sep 11, 2:01 AM
Unknown Object (File)
Wed, Sep 11, 1:59 AM
Subscribers

Details

Summary

Related Linear issue here. This is part of a set of diffs that will allow ShellCheck to be added to the CI. See inline comments for specific details of the ShellCheck error/warning output.

Test Plan

ShellCheck

Not entirely sure when this script is run, but the changes in this file are comments and adding double quotes, so I'm reasonably assuming it will continue to work as expected. My guess is this is a pre-commit script, but since I didn't commit any Rust code I don't know if it's still working. Adding @varun as a reviewer because Rust.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

abosh added a reviewer: varun.
abosh added a subscriber: varun.

I don't have much context on this script I think, and I'm a bad choice for a first-pass reviewer except for cases listed here

atul requested changes to this revision.Aug 2 2022, 11:17 AM

Not entirely sure when this script is run

I think you should be able to figure this out pretty easily by searching through the codebase

My guess is this is a pre-commit script, but since I didn't commit any Rust code I don't know if it's still working.

Once you find out where it's being run, you should be able to make a noop change to a file (add a print statement or something) and create a commit and see what happens.

This revision now requires changes to proceed.Aug 2 2022, 11:17 AM

I think you should be able to figure this out pretty easily by searching through the codebase

Haha, yeah. Looks like it's run anytime there's a change to a Rust file. From .lintstagedrc.js:

'services/commtest/**/*.rs': function rustFormat(files) {
  return 'yarn rust-pre-commit';
},

Made a no-op commit (added a print statement) and it worked:

image.png (1×2 px, 367 KB)

I think the real way to test that the script still works would be to make an invalid formatting change, like add some random line break in a rust file, and then try committing the change. If committing fails, the script still works as expected

In D4718#136074, @varun wrote:

I think the real way to test that the script still works would be to make an invalid formatting change, like add some random line break in a rust file, and then try committing the change. If committing fails, the script still works as expected

Yeah that's a much better approach

In D4718#136074, @varun wrote:

I think the real way to test that the script still works would be to make an invalid formatting change, like add some random line break in a rust file, and then try committing the change. If committing fails, the script still works as expected

Done!

image.png (1×1 px, 572 KB)

This revision is now accepted and ready to land.Aug 3 2022, 2:35 PM