GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Feature: Set nonzero exit code with --critical · Issue #42 · github/git-sizer

Feature: Set nonzero exit code with --critical #42

New issue
Copy link
New issue
Copy link
Open
Open
Feature: Set nonzero exit code with --critical#42
Copy link

Description

@mingalsuo
mingalsuo
opened on Jun 8, 2018
Issue body actions

For automation purposes, it would be a great feature to be able to analyze repositories and get a machine readable exit code that states that critical issues were found.

One way is to directly have --critical set the exit code or add another flag that does that if critical issues were found.

Thanks for creating this great tool.

Activity

  1. mhagger commented on Jun 12, 2018

    @mhagger
    mhagger
    on Jun 12, 2018
    Member
    More actions

    That's a good idea. We'd definitely want a way to distinguish between runtime errors (e.g., repository was corrupt) vs. size "errors"; for example, by returning different exit codes.

  2. sspaink commented on Oct 2, 2018

    @sspaink
    sspaink
    on Oct 2, 2018
    More actions

    I like this idea and I have some time to work on it.
    @mhagger did you maybe have some recommended exit codes in mind? I'm not aware of any standard command line error codes we could reuse.

    Following @mingalsuo description updating the tool to support custom user defined exit codes could be an approach. Have the user provide a config file with them listed.

  3. ls-jad-elkik commented on Feb 22, 2022

    @ls-jad-elkik
    ls-jad-elkik
    on Feb 22, 2022
    More actions

    A "nice" workaround is to use JSON output and jq.

    To just display the results:

    git-sizer --json --json-version=2 2>/dev/null | jq -r '. | values[] | select (.levelOfConcern >= 1) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)] | @tsv' | column -t -s $'\t'

    To set the exit code to 1 when all is good (there is no match >= threshold):

    git-sizer --json --json-version=2 2>/dev/null | jq -e -r '. | values[] | select (.levelOfConcern >= 1) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)]'

    Then you can "reverse" the exit code.

    You can tweak the threshold in select (.levelOfConcern >= 1), or a bit fancier with an env var:

    export THRESHOLD=0.5
    git-sizer --json --json-version=2 2>/dev/null | jq -e -r '. | values[] | select (.levelOfConcern >= (env.THRESHOLD | tonumber)) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)]'

    This can be further cleaned up in a nice zsh/bash wrapper file and/or a nice jq script file.

  4. murayamajpeg commented on May 25, 2024

    @murayamajpeg
    murayamajpeg
    on May 25, 2024
    More actions

    git cat-file -p :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.