Permalink
Browse files

look for .git/config up the parent dirs, allow gitc command to be use…

…d in subdirs
  • Loading branch information...
1 parent f4da050 commit 2ba79ef09557ee5ccc5aba36d66d0bd863f0ab06 @tongueroo tongueroo committed Mar 17, 2013
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/gitcycle.rb
View
16 lib/gitcycle.rb
@@ -800,9 +800,21 @@ def load_config
end
end
+ def git_config_path(path)
+ config = "#{path}/.git/config"
+ if File.exists?(config)
+ return config
+ elsif path == '/'
+ return nil
+ else
+ path = File.expand_path(path + '/..')
+ git_config_path(path)
+ end
+ end
+
def load_git
- path = "#{Dir.pwd}/.git/config"
- if File.exists?(path)
+ path = git_config_path(Dir.pwd)
+ if path
@git_url = File.read(path).match(/\[remote "origin"\][^\[]*url = ([^\n]+)/m)[1]
@git_repo = @git_url.match(/\/(.+)\./)[1]
@git_login = @git_url.match(/:(.+)\//)[1]

0 comments on commit 2ba79ef

Please sign in to comment.