Merge branch '44488-open-editor-when-creating-a-new-changelog-entry' into 'master'

Resolve "Use $EDITOR or another Environment variable to open the new Changelog entry directly in your editor"

Closes #44488

See merge request gitlab-org/gitlab-ce!18020
This commit is contained in:
Robert Speicher 2019-01-16 19:58:43 +00:00
commit 906c24e463
1 changed files with 9 additions and 1 deletions

View File

@ -148,7 +148,7 @@ class ChangelogEntry
def execute
assert_feature_branch!
assert_title!
assert_title! unless editor
assert_new_file!
# Read type from $stdin unless is already set
@ -162,6 +162,10 @@ class ChangelogEntry
write
amend_commit if options.amend
end
if editor
system("#{editor} '#{file_path}'")
end
end
private
@ -180,6 +184,10 @@ class ChangelogEntry
File.write(file_path, contents)
end
def editor
ENV['EDITOR']
end
def amend_commit
fail_with "git add failed" unless system(*%W[git add #{file_path}])