Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Output to YAML #41

Copy link
Copy link
@samrocketman

Description

@samrocketman
Issue body actions

It would be cool if this outputs to YAML. Do you accept pull requests?

Here's a fast proof of concept I use with awk.

Example output

The following example assumes I have ~/usr/bin in my $PATH.

$ curl -sSfL https://github.com/hmarr/codeowners/releases/download/v1.2.1/codeowners_1.2.1_darwin_arm64.tar.gz | tar -xz -C ~/usr/bin/ codeowners

$ cat > ~/usr/bin/codeowners-to-yaml.awk <<'EOF'
#!/usr/bin/awk -f
BEGIN {
    print "codeowners:";
};
{
    print "  - file: \""$1"\"\n    reviewers:";
    for(i=2; i<=NF; i++) {
        print "      - \""$i"\"";
    }
}
EOF

$ chmod 755 ~/usr/bin/codeowners-to-yaml.awk

$ git diff --diff-filter=AM --name-only "$(git merge-base origin/main HEAD)" HEAD | xargs codeowners | codeowners-to-yaml.awk
codeowners:
  - file: "some-file"
    reviewers:
      - "@org/team1"
      - "@org/team2"
  - file: "another-file"
    reviewers:
      - "@org/team3"

The YAML produced by the above PoC from codeowners output.

codeowners:
  - file: "some-file"
    reviewers:
      - "@org/team1"
      - "@org/team2"
  - file: "another-file"
    reviewers:
      - "@org/team3"
tplass-ias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.