Class: MGit::OperationProgressManager

Inherits:
Object
  • Object
show all
Defined in:
lib/m-git/foundation/operation_progress_manager.rb

Constant Summary collapse

PROGRESS_TYPE =
{
    :merge  =>  'merge_in_progress',
    :rebase =>  'rebase_in_progress',
    :pull   =>  'pull_in_progress'
}.freeze

Class Method Summary collapse

Class Method Details

.is_in_progress?(root, type) ⇒ Boolean

是否处于中间态中

Returns:

  • (Boolean)


101
102
103
104
105
106
107
108
109
110
111
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 101

def is_in_progress?(root, type)
  is_in_progress = false
  begin
    MGitConfig.query(root) { |config|
      is_in_progress = !config[type].nil?
    }
  rescue Error => e
    Output.puts_fail_message(e.msg)
  end
  return is_in_progress
end

.load_context(root, type) ⇒ OperationProgressContext,String

加载中间态上下文

Parameters:

  • root (String)

    多仓库根目录

  • type (String)

    自定义Key值,用于索引中间态信息

Returns:



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 121

def load_context(root, type)
  context = nil
  error = nil
  begin
    MGitConfig.query(root) { |config|
      dict = config[type]
      context = OperationProgressContext.new(type)
      context.deserialize(dict)
    }
  rescue Error => e
    Output.puts_fail_message(e.msg)
    error = e.msg
  end
  return context, error
end

.remove_progress(root, type) ⇒ Object

删除中间态

Parameters:

  • root (String)

    多仓库根目录

  • type (String)

    自定义Key值,用于索引中间态信息



90
91
92
93
94
95
96
97
98
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 90

def remove_progress(root, type)
  begin
    MGitConfig.update(root) { |config|
      config.delete(type)
    }
  rescue Error => e
    Output.puts_fail_message(e.msg)
  end
end

.trap_into_progress(root, context) ⇒ Object

进入中间态

Parameters:



74
75
76
77
78
79
80
81
82
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 74

def trap_into_progress(root, context)
  begin
    MGitConfig.update(root) { |config|
      config[context.type] = context.serialize
    }
  rescue Error => e
    Output.puts_fail_message(e.msg)
  end
end