lib/teapot/command/fetch.rb in teapot-3.5.2 vs lib/teapot/command/fetch.rb in teapot-3.5.3
- old
+ new
@@ -120,11 +120,19 @@
def credentials(url, username, types)
# We should prompt for username/password if required...
return Rugged::Credentials::SshKeyFromAgent.new(username: username)
end
-
+
+ def modified?(repository)
+ repository.status.each do |path, status|
+ return true if status != [:ignored]
+ end
+
+ return false
+ end
+
def clone_or_pull_package(context, configuration, package, package_lock, logger)
logger.info "Processing #{package}..." #.color(:cyan)
# Where we are going to put the package:
destination_path = package.path
@@ -148,10 +156,10 @@
logger.info "Updating package at path #{destination_path}..."
repository = Rugged::Repository.new(destination_path.to_s)
# Are there uncommitted changes in the work tree?
- if repository.to_enum(:status).any?
+ if modified?(repository)
raise FetchError.new(package, "Uncommited local modifications")
end
repository.fetch('origin', credentials: self.method(:credentials))
repository.checkout(branch_name) if branch_name