Support for remotes not called "origin"

Issue #11 resolved
Kevin Sarsen created an issue

When the underlying Stash repository does not contain a remote called origin, the tool throws the following error:

stash pull-request dev test --trace
/usr/local/lib/ruby/2.1.0/uri/common.rb:267:in `extract': undefined method `scan' for nil:NilClass (NoMethodError)
        from /usr/local/lib/ruby/2.1.0/uri/common.rb:813:in `extract'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/lib/atlassian/stash/git.rb:20:in `get_remote_url'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/lib/atlassian/stash/repo_info.rb:40:in `create'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/lib/atlassian/stash/pull_request.rb:58:in `create_pull_request'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/bin/stash:84:in `block (3 levels) in <top (required)>'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/lib/atlassian/stash/git.rb:25:in `ensure_within_git!'
        from /usr/local/lib/ruby/gems/2.1.0/gems/atlassian-stash-0.1.9/bin/stash:82:in `block (2 levels) in <top (required)>'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:180:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:180:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:155:in `run'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/runner.rb:422:in `run_active_command'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/runner.rb:82:in `run!'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/delegates.rb:8:in `run!'
        from /usr/local/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/import.rb:10:in `block in <top (required)>'

Comments (5)

  1. Kevin Sarsen reporter

    Changing this to an enhancement request because I discovered that the code is hard-coded to look for 'origin' and there are times when a repository may have a different name (i.e. multiple repositories). Users should be able to pass the repository name as an argument.

  2. Kevin Sarsen reporter

    Just for clarification and possibly to help others figure out their similar issues, my problem was caused by my repository being named something other than 'origin'. I had multiple repositories named 'stash-1' and 'stash-2'. When this method was executed in git.rb:

     def get_remote_url
            origin = get_remotes.split("\n").collect { |r| r.strip }.grep(/^origin.*\(push\)$/).first
            URI.extract(origin).first
     end
    

    the repository 'origin' wasn't found and it erred out. I renamed my primary repository to 'origin' and the error went away.

  3. Log in to comment