Skip to content

fix(color): no color for non-tty#611

Merged
ecrupper merged 2 commits intomainfrom
fix/color-term
Jun 10, 2025
Merged

fix(color): no color for non-tty#611
ecrupper merged 2 commits intomainfrom
fix/color-term

Conversation

@wass3r
Copy link
Collaborator

@wass3r wass3r commented May 29, 2025

fixes go-vela/community#1056

avoids issues when you have color output enabled but are sending output to non-terminal. example (typically, the scenario is that you might have color enabled globally):

$ vela --color true view repo --org <org> --repo <repo> --output json | jq -r '.'

currently results in:

jq: parse error: Invalid numeric literal at line 1, column 2

due to color codes in response. this simple fix in the PR overrides color output in such scenarios so users don't have to manually strip color code prior to working with the data when piping to other utils.

@wass3r wass3r requested a review from a team as a code owner May 29, 2025 04:39
@wass3r wass3r changed the title fix(color): no color for non-terminal fix(color): no color for non-tty May 29, 2025
@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.84%. Comparing base (484d694) to head (399e412).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/output/color.go 0.00% 4 Missing ⚠️

❌ Your project status has failed because the head coverage (74.84%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #611      +/-   ##
==========================================
- Coverage   74.87%   74.84%   -0.04%     
==========================================
  Files         173      173              
  Lines        7902     7906       +4     
==========================================
  Hits         5917     5917              
- Misses       1681     1685       +4     
  Partials      304      304              
Files with missing lines Coverage Δ
internal/output/color.go 6.45% <0.00%> (-0.96%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@colindean
Copy link
Contributor

I'm desperately wanting this today as my team will have a need to list secrets a lot in the next couple of weeks as we do a minor refactor of our Vela config as we migrate ~120 repos to a new directory layout, among other things.

@plyr4
Copy link
Contributor

plyr4 commented Jun 10, 2025

heck yeah good catch, thanks yall

@ecrupper ecrupper merged commit 1624c7f into main Jun 10, 2025
19 of 20 checks passed
@ecrupper ecrupper deleted the fix/color-term branch June 10, 2025 15:05
@colindean
Copy link
Contributor

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vela CLI emits ANSI color codes when stdout is not a tty

4 participants