lib/vendorificator/vendor/git.rb in vendorificator-0.3.0 vs lib/vendorificator/vendor/git.rb in vendorificator-0.4.0
- old
+ new
@@ -4,23 +4,10 @@
module Vendorificator
class Vendor::Git < Vendor
arg_reader :repository, :revision, :tag, :branch
attr_reader :conjured_revision
- def initialize(environment, name, args={}, &block)
- args[:version] ||= args[:tag] if args[:tag]
- if [:revision, :tag, :branch].select { |key| args.key?(key) }.count > 1
- raise ArgumentError, "You can provide only one of: :revision, :tag, :branch"
- end
-
- unless args.include?(:repository)
- args[:repository] = name
- name = name.split('/').last.sub(/\.git$/, '')
- end
- super(environment, name, args, &block)
- end
-
def conjure!
shell.say_status :clone, repository
MiniGit.git :clone, repository, '.'
local_git = MiniGit.new('.')
@@ -31,10 +18,11 @@
end
super
@conjured_revision = local_git.capturing.rev_parse('HEAD').strip
+ add_git_metadata
FileUtils::rm_rf '.git'
end
def upstream_version
tag || conjured_revision
@@ -45,9 +33,28 @@
rv << "version #{version} " if version
rv << "from tag #{tag} " if tag
rv << "from branch #{branch} " if branch
rv << "at revision #{conjured_revision}"
rv
+ end
+
+ private
+
+ def add_git_metadata
+ @metadata[:git_revision] = conjured_revision
+ end
+
+ def parse_initialize_args(args = {})
+ args[:version] ||= args[:tag] if args[:tag]
+ if [:revision, :tag, :branch].select { |key| args.key?(key) }.count > 1
+ raise ArgumentError, "You can provide only one of: :revision, :tag, :branch"
+ end
+
+ unless args.include?(:repository)
+ args[:repository] = @name
+ @name = @name.split('/').last.sub(/\.git$/, '')
+ end
+ super args
end
end
class Config
register_module :git, Vendor::Git