Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
feat(pull-request): do not open editor when user has use_editor set t…
Browse files Browse the repository at this point in the history
…o false

Especially useful for user in CI context and they have no control over their editor being
opened or not.

re #719
  • Loading branch information
Ryan Garant committed Nov 5, 2019
1 parent 3f79fa5 commit 9e810c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions default.gh.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

"github_user": "",

"use_editor": true,

"hooks": {
"issue": {
"close": {
Expand Down
14 changes: 8 additions & 6 deletions src/cmds/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,12 @@ async function close(options) {
}

async function comment(options) {
const useEditor = options.config.use_editor !== false

let body =
logger.applyReplacements(options.comment, options.config.replace) + options.config.signature

if (userLeftMsgEmpty(body)) {
if (useEditor && userLeftMsgEmpty(body)) {
body = openFileInEditor(
'temp-gh-pr-comment.md',
'<!-- Add an pr comment message in markdown format below -->'
Expand Down Expand Up @@ -828,6 +830,7 @@ function sortPullsByComplexity_(pulls, direction) {
}

async function submit(options, user) {
const useEditor = options.config.use_editor !== false
let description = options.description
let title = options.title
let pullBranch = options.pullBranch || options.currentBranch
Expand All @@ -837,15 +840,14 @@ async function submit(options, user) {
}

if (userLeftMsgEmpty(title)) {
title = openFileInEditor(
'temp-gh-pr-title.txt',
`# Add a pr title message on the next line\n${git.getLastCommitMessage(pullBranch)}`
)
title = useEditor
? openFileInEditor('temp-gh-pr-title.txt', `# Add a pr title message on the next line`)
: git.getLastCommitMessage(pullBranch)
}

// If user passes an empty title and description, --description will get merged into options.title
// Need to reference the original title not the potentially modified one
if (userLeftMsgEmpty(options.title) || userLeftMsgEmpty(description)) {
if (useEditor && (userLeftMsgEmpty(options.title) || userLeftMsgEmpty(description))) {
description = openFileInEditor(
'temp-gh-pr-body.md',
'<!-- Add an pr body message in markdown format below -->'
Expand Down

0 comments on commit 9e810c4

Please sign in to comment.