Class: Pindo::Command::Utils::Repoinit
- Inherits:
-
Pindo::Command::Utils
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Utils
- Pindo::Command::Utils::Repoinit
- Defined in:
- lib/pindo/command/utils/repoinit.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Repoinit
constructor
A new instance of Repoinit.
- #run ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run, use_cache?
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from HelpValidator
Constructor Details
#initialize(argv) ⇒ Repoinit
Returns a new instance of Repoinit.
44 45 46 47 48 49 50 51 |
# File 'lib/pindo/command/utils/repoinit.rb', line 44 def initialize(argv) @options = (argv) @enable_cliff = @options[:cliff] || false super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
36 37 38 |
# File 'lib/pindo/command/utils/repoinit.rb', line 36 def self.option_items @option_items ||= Pindo::Options::UtilsOptions.select(:cliff) end |
.options ⇒ Object
40 41 42 |
# File 'lib/pindo/command/utils/repoinit.rb', line 40 def self. option_items.map(&:to_claide_option).concat(super) end |
Instance Method Details
#run ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pindo/command/utils/repoinit.rb', line 53 def run pindo_project_dir = Dir.pwd unless Pindo::GitHandler.is_git_directory?(local_repo_dir: pindo_project_dir) Funlog.instance.("当前目录不是 Git 仓库,跳过初始化") return end current_git_root_path = Pindo::GitHandler.git_root_directory(local_repo_dir: pindo_project_dir) git_repo_helper = Pindo::GitRepoHelper.share_instance # 1. 检查并补充 .gitignore 规则 git_repo_helper.check_gitignore(current_git_root_path) # 2. 安装 commit 变更统计 hook(主仓库 + 子模块,支持 Husky) Pindo::GitHookHelper.share_instance.install_commit_stats_hook(current_git_root_path) # 3. 指定 --cliff 参数时,才检测安装 git-cliff 并初始化配置 if @enable_cliff git_repo_helper.check_and_install_cliff(pindo_project_dir) end end |