Skip to content

Instantly share code, notes, and snippets.

@rbrooks
Last active October 5, 2022 16:47
Show Gist options
  • Save rbrooks/ade2afa4db5d5fb09ab8cf2b3651f943 to your computer and use it in GitHub Desktop.
Save rbrooks/ade2afa4db5d5fb09ab8cf2b3651f943 to your computer and use it in GitHub Desktop.
Get Code Owner from CODEOWNERS
# Given a path on CODEOWNERS file, returns the username of code owner.
# CODEOWNERS file is either space or Tab-delimated. Hence the 2nd `cut` that slices on Tab.
# That's an actual Tab char between the ' '. It wouldn't accept '\t'.
# Here it is working on a Tab-deleimited line:
grep app/interactors/account/assign_reports_to/ .github/CODEOWNERS | cut -f2- -d ' ' | cut -f2- -d ' '
# @templeman15
# Here it is working on a Space-deleimited line:
grep app/models/paywall_registry.rb .github/CODEOWNERS | cut -f2- -d ' ' | cut -f2- -d ' '
# @bwarni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment