Skip to content

Commit

Permalink
Don’t output logging if no tty (#710)
Browse files Browse the repository at this point in the history
Closes #703
  • Loading branch information
mxcl authored Sep 12, 2023
1 parent dfde2f3 commit a21069c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.shellcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ jobs:
with:
path: /usr/local/bin
name: tea
# create a fork bomb, but since it’s via tea we prevent it
- run: |
echo '#!/bin/sh' > foo
echo 'tea -- /bin/sh "$0"' >> foo
Expand All @@ -334,3 +335,32 @@ jobs:
if ./foo; then
exit 1
fi
no-shell-output-if-no-tty:
needs: compile
runs-on: ubuntu-latest
container:
image: archlinux:latest # lazygit fails for reasons that are mysterious
options: -t
steps:
- uses: actions/download-artifact@v3
with:
path: /usr/local/bin
name: tea

- name: prep
run: |
chmod u+x /usr/local/bin/tea
#TODO ideally we'd test something that uses another tool in tea and
# is poorly written so it reads both stdout and stderr eg `lazygit`
# but CI doesn't have ttys and I couldn't figure out another way
# ref https://github.com/actions/runner/issues/241
#NOTE CI has no ttys so the opposite test is v. hard to achieve
- run: |
tea echo 2> >(tee temp_file) >/dev/null
if [[ -s temp_file ]]; then
echo
echo 'tea output logging info when no tty present'
exit 1
fi
Empty file added 1
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ brew install teaxyz/pkgs/tea-cli
```

> * [docs.tea.xyz/installing-w/out-brew]
> * [Migrating from tea v0](https://slack-files.com/T02MTUY60NS-F05NRQ8CT51-a881910f74)
> * [Migrating from tea v0](https://tea.xyz/blog/tea-1-0-0-alpha-1/)
 

Expand Down
44 changes: 44 additions & 0 deletions file
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--config-env=<name>=<envvar>] <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
3 changes: 2 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
}
} break
case 'install':
await ensure_pantry()
await install(await Promise.all(opts.args.map(x => parse_pkg_str(x, {latest: 'ok'}))))
break
case 'deintegrate':
Expand Down Expand Up @@ -108,7 +109,7 @@ async function ensure_pantry() {

function make_logger(verbosity: number, logger_prefix?: string): IInstallLogger {
const logger = new Logger(logger_prefix)
if (verbosity <= -2) {
if (verbosity <= -2 || !Deno.isatty(Deno.stderr.rid)) {
return {
replace: () => {},
clear: () => {},
Expand Down

0 comments on commit a21069c

Please sign in to comment.