Show a quick panel with commits to be chosen from as compare against. Arguments: git_gutter (GitGutterCommand): The main command object, which represents GitGutter. kwargs (dict): The arguments received from the `run_command`. This argument is declared to
(git_gutter, **kwargs)
| 36 | |
| 37 | |
| 38 | def set_against_file_commit(git_gutter, **kwargs): |
| 39 | """Show a quick panel with commits to be chosen from as compare against. |
| 40 | |
| 41 | Arguments: |
| 42 | git_gutter (GitGutterCommand): The main command object, which |
| 43 | represents GitGutter. |
| 44 | kwargs (dict): The arguments received from the `run_command`. |
| 45 | This argument is declared to create a common interface being used |
| 46 | by the GitGutterCommand object. |
| 47 | """ |
| 48 | def show_quick_panel(output): |
| 49 | """Parse git output and present the quick panel. |
| 50 | |
| 51 | Arguments: |
| 52 | output (string): The output of git with the list of commits. |
| 53 | """ |
| 54 | if not output: |
| 55 | return sublime.message_dialog( |
| 56 | 'No commits of this file found in repository.') |
| 57 | |
| 58 | # Sort items by author date in reversed order, |
| 59 | # split each line by \a and strip time stamp from beginning |
| 60 | items = [ |
| 61 | r[1:-1].split('\a')[1:] |
| 62 | for r in sorted(output.split('\n'), reverse=True) |
| 63 | ] |
| 64 | |
| 65 | def on_done(index): |
| 66 | """Select new compare target according to user selection.""" |
| 67 | if index > -1: |
| 68 | git_gutter.git_handler.set_compare_against( |
| 69 | items[index][0].split(' ')[0]) |
| 70 | |
| 71 | git_gutter.view.window().show_quick_panel(items, on_done) |
| 72 | |
| 73 | git_gutter.git_handler.git_file_commits().then(show_quick_panel) |
| 74 | |
| 75 | |
| 76 | def set_against_branch(git_gutter, **kwargs): |
nothing calls this directly
no test coverage detected