mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(pr): strip terminal control sequences from pr diff on a terminal
pr diff copied the server's patch bytes straight to stdout, so a pull request could change the terminal title, clear the screen or move the cursor of whoever viewed its diff. Add terminal.SafeWriter, which filters streamed server text like terminal.SafeText when stdout is a terminal, and use it for pr diff. Piped output stays byte-exact, so `tea pr diff N | git apply` keeps working. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+158
-1
No files matched your search
@@ -96,7 +96,7 @@ func (a *application) addPullMutations(group *cobra.Command) {
|
||||
return err
|
||||
}
|
||||
defer body.Close()
|
||||
_, err = io.Copy(cmd.OutOrStdout(), body)
|
||||
_, err = io.Copy(terminal.SafeWriter(cmd.OutOrStdout(), a.deps.Streams.OutTTY, false), body)
|
||||
return err
|
||||
}})
|
||||
group.AddCommand(a.pullReviewCommand())
|
||||
|
||||
Reference in new issue
Block a user