Module: MGit::Template

Defined in:
lib/m-git/template/pre_hook.rb,
lib/m-git/template/post_hook.rb,
lib/m-git/template/manifest_hook.rb,
lib/m-git/template/pre_exec_hook.rb,
lib/m-git/template/pre_push_hook.rb,
lib/m-git/template/local_manifest.rb,
lib/m-git/template/post_download_hook.rb

Constant Summary collapse

PRE_CUSTOMIZED_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class PreHook

  # hook接口,用于接受本次指令执行前的数据
  #
  # @param cmd [String] 本次执行指令
  #
  # @param opts [String] 本次执行指令参数
  #
  # @param mgit_root [String] mgit根目录
  #
  def self.run(cmd, opts, mgit_root)

  end

end

end
'
POST_CUSTOMIZED_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class PostHook

  # hook接口,用于接受本次指令执行后的数据
  #
  # @param cmd [String] 本次执行指令
  #
  # @param opts [String] 本次执行指令参数
  #
  # @param mgit_root [String] mgit根目录
  #
  # @param exec_repos [Array<Manifest::LightRepo>] 本次执行指令的LightRepo数组
  #
  def self.run(cmd, opts, mgit_root, exec_repos)

  end

end

end
'
MANIFEST_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class ManifestHook

  # hook接口,用于生成manifest.json文件。文件本地地址必须设置为<PROJ_ROOT>/.mgit/source-config/manifest.json
  #
  # 若解析失败,可抛出异常:
  #
  #     raise MGit::Error.new("失败原因...", type: MGit::MGIT_ERROR_TYPE[:config_generate_error])
  #
  # 异常抛出后程序终止
  def self.run()

  end

end

end
'
PRE_CUSTOMIZED_EXEC_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class PreExecHook

  # hook接口,用于接受本次指令执行前的数据
  #
  # @param cmd [String] 本次执行指令
  #
  # @param opts [String] 本次执行指令参数
  #
  # @param mgit_root [String] mgit根目录
  #
  # @param exec_repos [Array<Manifest::LightRepo>] 本次执行指令的LightRepo数组
  #
  def self.run(cmd, opts, mgit_root, exec_repos)

  end

end

end
'
PRE_CUSTOMIZED_PUSH_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class PrePushHook

  # hook接口,用于接受push指令执行后的数据
  #
  # @param cmd [String] 本次执行指令
  #
  # @param opts [String] 本次执行指令参数
  #
  # @param mgit_root [String] mgit根目录
  #
  # @param exec_repos [Array<Manifest::LightRepo>] 本次执行指令的LightRepo数组
  #
  def self.run(cmd, opts, mgit_root, exec_repos)

  end

end

end
'
POST_DOWNLOAD_HOOK_TEMPLATE =
'
#coding=utf-8

module MGitTemplate

class PostDownloadHook

  # hook接口,单个仓库下载完成后调用
  #
  # @param name [String] 下载仓库名
  #
  # @param path [String] 下载仓库的本地绝对路径
  #
  # @return [Boolean] 是否改动仓库HEAD
  #
  def self.run(name, path)

  end

end

end
'

Class Method Summary collapse

Class Method Details

.default_templateObject



6
7
8
9
10
11
12
13
# File 'lib/m-git/template/local_manifest.rb', line 6

def default_template
  return "{
  \"#{Constants::CONFIG_KEY[:repositories]}\": {

  }
}
"
end

.local_config_template(config_repo_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/m-git/template/local_manifest.rb', line 15

def local_config_template(config_repo_name)
  return "{
  \"#{Constants::CONFIG_KEY[:mgit_excluded]}\": true,
  \"#{Constants::CONFIG_KEY[:repositories]}\": {
\"#{config_repo_name}\": {
  \"#{Constants::REPO_CONFIG_KEY[:mgit_excluded]}\": false
}
  }
}
"
end