-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddNewlineAction: A new action for GitCommitBear
This adds a new action which adds a newline between shortlog and body of commit message when applied. This also make changes in CommitBear.py to pass AddNewlineAction when Result is yielded
- Loading branch information
1 parent
fd5a5a7
commit 077b0aa
Showing
3 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from coalib.misc.Shell import run_shell_command | ||
from coalib.results.result_actions.ResultAction import ResultAction | ||
|
||
|
||
class AddNewlineAction(ResultAction): | ||
|
||
SUCCESS_MESSAGE = 'New Line added successfully.' | ||
|
||
def __init__(self, shortlog, body): | ||
self.shortlog = shortlog | ||
self.body = body | ||
|
||
@staticmethod | ||
def is_applicable(result, | ||
original_file_dict, | ||
file_diff_dict, | ||
applied_actions=()): | ||
return 'AddNewlineAction' not in file_diff_dict | ||
|
||
def apply(self, result, original_file_dict, file_diff_dict): | ||
""" | ||
Add New(L)ine | ||
""" | ||
new_commit_message = '{}\n\n{}'.format(self.shortlog, self.body) | ||
command = 'git commit --amend -m "{}"'.format(new_commit_message) | ||
stdout, err = run_shell_command(command) | ||
file_diff_dict['AddNewlineAction'] = True | ||
return file_diff_dict |
Empty file.