Opens specified text editor when creating a new changelog entry

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Tiago Botelho 2018-03-27 16:06:31 +01:00 committed by Rémy Coutable
parent 8285205815
commit 83106427c8
No known key found for this signature in database
GPG Key ID: 98DFFD1C0C62B70B
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}])