lib/prick/local/git.rb in prick-0.39.5 vs lib/prick/local/git.rb in prick-0.39.6
- old
+ new
@@ -1,10 +1,10 @@
module Prick
module Git
# Return the origin of the repository
- def self.origin()
+ def self.origin()
Command.command("git remote get-url origin").first
end
# Clone a repository
def self.clone(url, directory = nil, branch: nil)
@@ -50,11 +50,11 @@
def self.pull
Command.command "git pull"
end
# Push change to repository
- def self.push
+ def self.push
Command.command "git push --quiet --atomic"
end
# Access to tag methods
def self.tag() Tag end
@@ -65,38 +65,38 @@
# List files in repository
def self.list() Command.command("git ls-files") end
module Tag
# The associated commit ID of a tag
- def self.id(tag)
- tag && Command.command("git rev-list -n 1 #{tag}").first
+ def self.id(tag)
+ tag && Command.command("git rev-list -n 1 #{tag}").first
end
# True if tag exists
- def self.exist?(tag)
- tag && Command.command?("git describe --tags #{tag}")
+ def self.exist?(tag)
+ tag && Command.command?("git describe --tags #{tag}")
end
# Create tag
- def self.create(tag, id: nil)
- Command.command "git tag '#{tag}' #{id}"
+ def self.create(tag, id: nil)
+ Command.command "git tag '#{tag}' #{id}"
end
# Drop a tag
- def self.drop(tag)
- Command.command "git tag -d '#{tag}'"
+ def self.drop(tag)
+ Command.command "git tag -d '#{tag}'"
end
# Return list of all tags. Not in any particular order
- def self.list()
- Command.command("git tag")
+ def self.list()
+ Command.command("git tag")
end
# Return the most recent tag before the given commit (defaults to the
# last commit)
- def self.current(id = nil)
- describe_tag(id)&.first
+ def self.current(id = nil)
+ describe_tag(id)&.first
end
private
# Return a [tag, number-of-commits, commit-id] tuple of the most recent
# tag. Return nil if no tag was found
@@ -113,15 +113,15 @@
end
end
end
module Branch
- def self.exist?(branch)
+ def self.exist?(branch)
Command.command? "git show-ref --verify --quiet refs/heads/#{branch}"
end
- def self.create(branch, id = nil, set_upstream: true)
+ def self.create(branch, id = nil, set_upstream: true)
if set_upstream
current = Git.branch.current
Command.command %(
git checkout --quiet -b #{branch} #{id}
git push --quiet --set-upstream origin #{branch}
@@ -130,23 +130,23 @@
else
Command.command "git branch #{branch} #{id}"
end
end
- def self.drop(branch)
+ def self.drop(branch)
Command.command "git branch -D #{branch}"
end
def self.list()
Command.command "git for-each-ref --format='%(refname:short)' refs/heads/*"
end
- def self.current()
+ def self.current()
Command.command("git branch --show-current").first
end
- def self.checkout(branch)
+ def self.checkout(branch)
Command.command "git checkout --quiet #{branch}"
end
end
end
end
@@ -156,10 +156,10 @@
def self.changed?(file)
Command.command("git status --porcelain").any? { |l| l =~ /^.M #{file}$/ }
end
-
+
# Return true if `version` has an associated tag
def self.tag?(version)
!list_tags.grep(version.to_s).empty?
end