Class: AppCommand::GitBranch

Inherits:
Convoy::ActionCommand::Base
  • Object
show all
Defined in:
lib/routes/git_branch.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
# File 'lib/routes/git_branch.rb', line 5

def execute

    @opts = command_options
    @sort = App::Git::SORT_REFNAME
    @git = App::Git.new
    opts_validate
    opts_routing

end

#list_local_branchesObject

List local branches.

Returns:

  • void



43
44
45
# File 'lib/routes/git_branch.rb', line 43

def list_local_branches
    @git.show_branches(@sort, App::Git::LOCAL)
end

#list_remote_branchesObject

List remote branches.

Returns:

  • void



49
50
51
# File 'lib/routes/git_branch.rb', line 49

def list_remote_branches
    @git.show_branches(@sort, App::Git::REMOTE)
end

#opts_routingObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/routes/git_branch.rb', line 25

def opts_routing

    if @opts[:local]
        list_local_branches
    elsif @opts[:remote]
        list_remote_branches
    else
        if @opts[:sortDate]
            system('bp g b -ld')
        else
            system('bp g b -l')
        end
    end

end

#opts_validateObject



15
16
17
18
19
20
21
22
23
# File 'lib/routes/git_branch.rb', line 15

def opts_validate

    if @opts[:remote] && @opts[:local]
        # @todo Change to new style error messages.
        abort('Cannot list both local & remote branches simultaneously. Please choose one option only.')
    end
    @sort = App::Git::SORT_DATE if @opts[:sortDate]

end