lib/travis/cli/repo_command.rb in travis-1.5.7.travis.338.4 vs lib/travis/cli/repo_command.rb in travis-1.5.7.travis.341.4

- old
+ new

@@ -1,19 +1,21 @@ require 'travis/cli' require 'yaml' +require "addressable/uri" module Travis module CLI class RepoCommand < ApiCommand - GIT_REGEX = %r{^(?:https://|git://|git@)github\.com[:/](.*/.+?)(\.git)?$} + GIT_REGEX = %r{/?(.*/.+?)(\.git)?$} on('-r', '--repo SLUG', 'repository to use (will try to detect from current git clone)') { |c, slug| c.slug = slug } attr_accessor :slug abstract def setup error "Can't figure out GitHub repo name. Ensure you're in the repo directory, or specify the repo name via the -r option (e.g. travis <command> -r <repo-name>)" unless self.slug ||= find_slug + error "GitHub repo name is invalid, it should be on the form 'owner/repo'" unless self.slug.include?("/") self.api_endpoint = detect_api_endpoint super repository.load # makes sure we actually have access to the repo end @@ -50,10 +52,10 @@ def find_slug git_head = `git name-rev --name-only HEAD 2>#{IO::NULL}`.chomp git_remote = `git config --get branch.#{git_head}.remote 2>#{IO::NULL}`.chomp git_remote = 'origin' if git_remote.empty? git_info = `git config --get remote.#{git_remote}.url 2>#{IO::NULL}`.chomp - $1 if git_info =~ GIT_REGEX + $1 if Addressable::URI.parse(git_info).path =~ GIT_REGEX end def repo_config config['repos'] ||= {} config['repos'][slug] ||= {}