Class: DevFlow::Info

Inherits:
App
  • Object
show all
Defined in:
lib/dev_flow/commands/info.rb

Instance Attribute Summary

Attributes inherited from App

#command, #config, #git, #logger, #members, #roadmap, #waiting

Instance Method Summary collapse

Methods inherited from App

#all_member_names, #ask_rebase, #debug, #display_close_waiting, #display_tasks, #error, #hello, #hr, #hrb, #hrbh, #hrh, #i_am_leader?, #i_am_moderator?, #i_am_supervisor?, #i_have_power?, #in_release?, #in_trunk?, #info, #initialize, #leader_name, #load_roadmap, #new_version, #switch_to!, #sync?, #task, #tasks_for_close, #upload_progress!, #user_name, #warn

Constructor Details

This class inherits a constructor from DevFlow::App

Instance Method Details

#process!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/dev_flow/commands/info.rb', line 16

def process!
  self.hello

  current_task = self.task
  if current_task or in_trunk?
    self.ask_rebase 
  else
    error "Not in a known task branch"
  end

  if current_task
    # if complete, switch to develop

    if current_task.is_completed?
      warn "Your task is completed and closed, now swith to develop trunk"
      `git checkout develop`
      warn "Your may want `dw clean` your local working directory"
      exit
    end      
  end

  puts hr

  # if i am the leader and there are closed branches, warn:

  if i_am_leader? and tasks_for_close.size > 0
    display_close_waiting
  else
    display_tasks
  end
  puts hrh

  if @git.wd_clean? 
    # if work directory is clean, ready to switch

    if i_am_leader? and in_release? # concentrate

      puts "You are in a release branch, please release it as soon as possible."
    else # otherwise show switch @config


      @config[:switch] = true if @git.current_branch == 'develop'
      if @config[:switch] and @config[:branch]
        switch_task = self.task @config[:branch]
        error "Can not find ROADMAP task for branch #{@config[:branch]}" unless switch_task
        switch_to! @config[:branch] if @config[:branch]
        update_task switch_task
      elsif @config[:switch]
        puts "You can switch to other branches:".bold.yellow
        puts "Type #{0.to_s.bold} to switch to develop trunk.".bold.blue unless @git.current_branch == 'develop'
        print @waiting.keys.join(", ") + ":"          
        ans = STDIN.gets.chomp!
        if ans == 0.to_s
          switch_to! 'develop'
          `git pull #{@config["git_remote"]} develop` if @config["git_remote"]
        elsif @waiting[ans.to_i]
          switch_to! @waiting[ans.to_i].branch_name
          update_task @waiting[ans.to_i]            
        else
          error "Invalid input #{ans}. Can not continue." if ans and ans.size > 0
        end
      else
        # dw show information only. quit.

      end
    end
  else # if the wd is not clean

    
    if current_task and in_release?
      if i_am_leader?
        puts "You are in a release branch, if you are ready to release it, use:"
        puts "  $ dw release".bold.blue
      else
        puts "WARN: You are on a release branch, only leader can edit release branches.".yellow
        puts "Please undo you edit. Do not push your edition to the remote server."
      end
      exit
    end

    if current_task and current_task.progress == 99
      if i_am_leader?
        puts "You are in a branch marked complete. Please test and review the code, and close it by:"
        puts "  $ dw close".bold.blue
        puts "Or reject the branch by issue:"
        puts "  $ dw progress 60".bold.blue
      else
        puts "WARN: You are on a completed branch, call the leader (#{leader_name.bold}) to close it.".yellow
      end
      exit
    end
    
    if current_task
      unless current_task.resources.include? @config["whoami"]
        puts "WARN: You are editing a task not assigned to you.".yellow
      end

      puts "You are encouraged to push your progress often by:"
      puts "  $ dw progress 40 'git commit message'".bold.blue
      puts "Or use the short version:"
      puts "  $ dw pg 40 'git commit message'".bold.blue
      puts "If you fully implemented and tested the code, issue:"
      puts "  $ dw complete"
      puts "to complete the task."
      # puts "Then #{'do not forget'.bold.red} inform the leader (#{leader_name.bold})."

    else
      puts "You are not on any non-branches. You may commit all you changes and"
      puts "switch to develop trunk before the next move:"
      puts "  $ git commit -am 'git commit message'".bold.blue
      puts "  $ git checkout develop".bold.blue
    end

    if in_trunk?
      if @git.current_branch == 'develop' and i_have_power?
        puts "You should only edit ROADMAP files on develop trunk, when you done, use:"
        puts "  $ dw update-roadmap".bold.blue
        puts "Or use the short version:"
        puts "  $ dw ur".bold.blue
      else
        warn "Avoid directly edit files under trunk branches."
        puts "Please undo you change and switch to work on a task branch."
      end
    end
    
  end
  hrb
end

#update_task(task) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/dev_flow/commands/info.rb', line 4

def update_task task
  if task.progress > 0
    # update your work directory

    `git pull #{@config["git_remote"]} #{task.branch_name}` if sync?
  else
    # if the task not started yet, update progress

    upload_progress!(task, 10)
  end

  ask_rebase
end