Class: Makit::Git::CLI
- Inherits:
-
Object
- Object
- Makit::Git::CLI
- Defined in:
- lib/makit/git/cli.rb
Overview
This class provides methods for executing git commands and operations that modify repository state.
Class Method Summary collapse
- .integrate ⇒ Object
- .pull ⇒ Object
- .sync ⇒ Object
- .tag(version) ⇒ Object
- .zip_source_files(zipfilename) ⇒ Object
Class Method Details
.integrate ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/makit/git/cli.rb', line 9 def self.integrate return unless Repository.git_repo? && !Repository.detached ## check for unstaged or untracked files unstaged_files = `git status --porcelain`.split("\n") untracked_files = `git ls-files --others --exclude-standard`.split("\n") return unless unstaged_files.length.positive? || untracked_files.length.positive? "git add .".run "git commit -m \"integrate\"".run unless Repository.clean? end |
.pull ⇒ Object
29 30 31 32 33 |
# File 'lib/makit/git/cli.rb', line 29 def self.pull return unless Repository.git_repo? && !Repository.detached "git pull".try end |
.sync ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/makit/git/cli.rb', line 21 def self.sync return unless Repository.git_repo? && !Repository.detached "git pull".try "git push origin".try "git push origin --tags".try end |
.tag(version) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/makit/git/cli.rb', line 39 def self.tag(version) # only tag if the repo is not read only if Repository.read_only? puts " cannot tag a read only repo".colorize(:red) return end # check if a tag for the current version already exists if `git tag -l v#{version}`.strip.length.positive? puts " tag v#{version} already exists".colorize(:red) else "git tag -a v#{version} -m \"version #{version}\"".run end end |
.zip_source_files(zipfilename) ⇒ Object
35 36 37 |
# File 'lib/makit/git/cli.rb', line 35 def self.zip_source_files(zipfilename) "git archive --format zip --output #{zipfilename} HEAD".run end |