Class: YJCocoa::GitCache
- Defined in:
- lib/yjcocoa/git/git_cache.rb
Constant Summary
Constants inherited from Command
Instance Attribute Summary collapse
-
#paths ⇒ Object
property.
Class Method Summary collapse
Instance Method Summary collapse
- #cleanRepository ⇒ Object
- #cleanWorkDirectory ⇒ Object
-
#initialize(argv) ⇒ GitCache
constructor
初始化.
- #pushOrigin ⇒ Object
- #run ⇒ Object
-
#validate! ⇒ Object
businrss.
Methods inherited from Git
Methods inherited from Command
Constructor Details
#initialize(argv) ⇒ GitCache
初始化
40 41 42 43 44 |
# 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 |
Instance Attribute Details
#paths ⇒ Object
property
37 38 39 |
# File 'lib/yjcocoa/git/git_cache.rb', line 37 def paths @paths end |
Class Method Details
.options ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/yjcocoa/git/git_cache.rb', line 28 def self. if self == YJCocoa::GitCache [['--delete-path', '删除的文件路径,多个路径用‘,’隔开']] + super else super end end |
Instance Method Details
#cleanRepository ⇒ Object
80 81 82 83 84 |
# 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 ⇒ Object
65 66 67 68 69 70 71 72 73 |
# 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 ⇒ Object
75 76 77 78 |
# 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 ⇒ Object
56 57 58 59 60 61 62 63 |
# 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! ⇒ Object
businrss
47 48 49 50 51 52 53 54 |
# File 'lib/yjcocoa/git/git_cache.rb', line 47 def validate! super exit 0 unless self.gitExist? unless self.paths puts "文件路径为空".red self. end end |