class YJCocoa::GitCache
Attributes
paths[RW]
property
Public Class Methods
new(argv)
click to toggle source
初始化
Calls superclass method
# File lib/yjcocoa/git/git_cache.rb, line 40 def initialize(argv) super self.paths = argv.option('delete-path') self.paths = self.paths.split(",").reject {|i| i.empty? } if self.paths end
options()
click to toggle source
Calls superclass method
YJCocoa::Command::options
# File lib/yjcocoa/git/git_cache.rb, line 28 def self.options if self == YJCocoa::GitCache [['--delete-path', '删除的文件路径,多个路径用‘,’隔开']] + super else super end end
Public Instance Methods
cleanRepository()
click to toggle source
# File lib/yjcocoa/git/git_cache.rb, line 80 def cleanRepository system("git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin") system("git reflog expire --expire=now --all") system("git gc --prune=now") end
cleanWorkDirectory()
click to toggle source
# File lib/yjcocoa/git/git_cache.rb, line 65 def cleanWorkDirectory self.paths.each { |path| puts "YJCocoa git delete cache #{path}".green system("git filter-branch --force --index-filter \ 'git rm -r --cached --ignore-unmatch #{path}' \ --prune-empty --tag-name-filter cat -- --all") puts } end
pushOrigin()
click to toggle source
# File lib/yjcocoa/git/git_cache.rb, line 75 def pushOrigin system("git push origin --force --all") system("git push origin --force --tags") end
run()
click to toggle source
# File lib/yjcocoa/git/git_cache.rb, line 56 def run self.cleanWorkDirectory answer = self.askWithAnswers("强制推动您的本地更改覆盖您的远端仓库", ["Yes", "No"]) if answer == "yes" self.pushOrigin self.cleanRepository end end
validate!()
click to toggle source
businrss
Calls superclass method
# File lib/yjcocoa/git/git_cache.rb, line 47 def validate! super exit 0 unless self.gitExist? unless self.paths puts "文件路径为空".red self.banner! end end