From 5b38515d10e01b1f64332f841ddfe3dc7f2df480 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Wed, 1 Jun 2016 12:56:59 -0700 Subject: [PATCH] Discover repository directory inside subdirectories Uses Rugged::Repository#discover to discover the location of the git repository if the current working directory is a subdirectory of the git repository. Working directory is changed to the root of the repository so that runners pick up the appropriate configuration files. --- lib/pronto/cli.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pronto/cli.rb b/lib/pronto/cli.rb index 5777195b..04d5acd0 100644 --- a/lib/pronto/cli.rb +++ b/lib/pronto/cli.rb @@ -49,7 +49,10 @@ def run(path = nil) formatters = ::Pronto::Formatter.get(options[:formatters]) commit = options[:index] ? :index : options[:commit] - messages = ::Pronto.run(commit, '.', formatters, path) + repo_workdir = ::Rugged::Repository.discover('.').workdir + messages = Dir.chdir(repo_workdir) do + ::Pronto.run(commit, '.', formatters, path) + end exit(messages.count) if options[:'exit-code'] rescue Rugged::RepositoryError puts '"pronto" should be run from a git repository'