feat: add whitelist char support to nonascii check #100
No reviewers
Labels
No Label
bug
component
executor
component
framework
component
parser
component
UI
duplicate
enhancement
help wanted
invalid
priority
p0
priority
p1
priority
p2
priority
p3
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: JOJ/JOJ3#100
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat_repo-healthcheck-whitelist-char"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This commit brings support of whitelisted characters during repo healthcheck/non-ascii file check. Supported by an extra switch to
repo-health-checker,-whitelistedChars. The argument takes a comma-separated list of non-ASCII characters and ignores them during repo healthcheck. Illegal cmdline input is logged by the logger.Co-Authored-By: GitHub Copilot noreply@microsoft.com
Copilot Prompt
This is a repo for an online judge orchestrator system «JOJ3». Under `cmd/` lies a source directory for a Go command, `repo-health-checker`. You tell from its name that it checks the repo for stuff like repo size, commit message, non-ASCII character usage, etc. before sending the work to the actual judging and grading system.
Now, I want the non-ASCII character checking function of the repo health checker to be flexible - it shall accept a list of non-ASCII characters and deem them acceptable.
Your task
cmd/repo-health-checker/main.go, accept a new command line flag-whitelisted-chars, which shall take exactly one string of comma-separated non-ASCII characters. This string shall be passed to the actual healthcheck package.pkg/healthcheck/nonascii.go, functiongetNonASCII(), we utilize a bufio Scanner to scan through all files for non-ASCII characters. We would like the list of acceptable chars to be passed from the cmdline to here, and modify the scanner logic to actually accept the corresponding characters.-whitelisted-chars, could be completely abscent; in which case, no characters shall be escaped by default. The comma-separated list passed to the command may contain ASCII characters or multiple characters that are not properly separated; in which case, ignore that element, and report the incident via the SLog logging framework used in this project.examples/healthcheck/to reflect this change. Reflect toexamples/healthcheck/asciifile/to learn about how to configure the repo health checker. Integrate your work to the Go test framework such that it could be invoked by runningmake testat the terminal.git initto init your testcase directory and make a initial commit - this project, JOJ3, only runs in Git repos.Notes
cmd/for invokable commands,pkg/for the actual logic,internal- something you don't need to worry about.joj3is a separate executable; in this session we are only working on therepo-health-checker.README.mdand the directory structure before you go; also, create To-do before you execute your plan.feat: add whitelist char support to nonascii checkto WIP: feat: add whitelist char support to nonascii checkWIP: feat: add whitelist char support to nonascii checkto feat: add whitelist char support to nonascii checkSince it just reads comma seperated strings, I think we can just pass it via
[]string, and no need to name it asxxxCSVas it is a bit confusing?Modified - removed "CSV" from "whitelistedCharsCSV". Note that it's passing a
string, not a[]stringsince it's from the command line.Also note that in function
parseWhitelistedChars, variable name "csv" is kept as-is to reflect the fact that it's a comma-separated list.LGTM
@bomingzh Thanks for the review :)
However I don't have the permission to merge :(
:-( I merged it with wrong order, it has conflicts now.
New commits pushed, approval review dismissed automatically according to repository settings
Merge conflict fixed