Skip to content

Fixes #2823 - Handle stdout/stderr Buffers in shell run()#2824

Merged
eamodio merged 2 commits intogitkraken:mainfrom
mogelbrod:main
Jul 20, 2023
Merged

Fixes #2823 - Handle stdout/stderr Buffers in shell run()#2824
eamodio merged 2 commits intogitkraken:mainfrom
mogelbrod:main

Conversation

@mogelbrod
Copy link
Contributor

@mogelbrod mogelbrod commented Jul 20, 2023

Description

Fixes #2823

Handles cases where stdout/stderr are Buffers in the shell run() helper:

let stdoutDecoded;
let stderrDecoded;
if (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {
stdoutDecoded = stdout;
stderrDecoded = stderr;
} else {
const decode = (await import(/* webpackChunkName: "encoding" */ 'iconv-lite')).decode;
stdoutDecoded = decode(Buffer.from(stdout, 'binary'), encoding);
stderrDecoded = decode(Buffer.from(stderr, 'binary'), encoding);
}
reject(new RunError(error, stdoutDecoded, stderrDecoded));

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@mogelbrod mogelbrod changed the title Fixes #2823 stdout/stderr Buffers in shell run() Fixes #2823 - Handle stdout/stderr Buffers in shell run() Jul 20, 2023
@mogelbrod mogelbrod marked this pull request as ready for review July 20, 2023 12:07
@eamodio eamodio merged commit 87efc38 into gitkraken:main Jul 20, 2023
@eamodio
Copy link
Member

eamodio commented Jul 20, 2023

Thank you so much for your contribution!

Thank you!

@eamodio eamodio added this to the 14.2 milestone Jul 20, 2023
@eamodio eamodio self-assigned this Jul 20, 2023
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.

Errors thrown by run() git shell helper are not properly handled

2 participants