Support personal repositories

Issue #3 resolved
Jeremy Edgell created an issue

The basic URL structure for user repos is:

https://stash.my-companys-domain.com:7999/scm/~myUser/repository.git

Running the command

stash --trace pull-request feature/FEATRUE-BRANCH-NAME develop @reviewersName

returns this:

/Library/Ruby/Gems/1.8/gems/atlassian-stash-0.1.6/bin/../lib/atlassian/stash/pullrequest.rb:54:in `extract_repository_info': Repository does not seem to be hosted in Stash (RuntimeError)
    from /Library/Ruby/Gems/1.8/gems/atlassian-stash-0.1.6/bin/../lib/atlassian/stash/pullrequest.rb:66:in `create_pull_request'
    from /Library/Ruby/Gems/1.8/gems/atlassian-stash-0.1.6/bin/stash:83
    from /Library/Ruby/Gems/1.8/gems/atlassian-stash-0.1.6/bin/../lib/atlassian/stash/git.rb:25:in `ensure_within_git!'
    from /Library/Ruby/Gems/1.8/gems/atlassian-stash-0.1.6/bin/stash:81
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/command.rb:155:in `run'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/runner.rb:402:in `run_active_command'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/runner.rb:78:in `run!'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/delegates.rb:7:in `run!'
    from /Library/Ruby/Gems/1.8/gems/commander-4.1.5/lib/commander/import.rb:10

Correcting the regular expression at line 54 in the pullrequest.rb file to this:

/\/([\~]?[a-zA-Z][a-zA-Z0-9_]*)\/([[:alnum:]][\w\-\.]*).git$/

fixes my problem, but I doubt this will be a valid option for others.

Comments (10)

  1. Jeremy Edgell reporter

    P.S.: Sorry, my ruby-fu is pretty weak, or I'd have offered more advice. PHP guy here...and can recognize a regular expression at twenty paces, so, that's the only reason I feel like I got that far :)

  2. Clint Checketts

    I'd love to create pull requests from my personal repo to the main project. That is the precise workflow we use on my project. Everyone commits to their own repo and create pull requests, no matter what role they have.

  3. Jeremy Edgell reporter

    @checketts that's our workflow as well. I forked this repo and reworked the line that generates the API URL to match that workflow. I felt like this was something that was specific to our workflow that may not have applied to this project. However, I feel like enabling personal repositories may be as simple as an if statement evaluating the format of the configured repository URL, but I don't personally have enough experience with the Stash API to say that with 100% certainty.

  4. Clint Checketts

    @jeremyclassic Does your workflow expect pull requests from your personal repo to the team's upstream repo?

    I fear the current command expects the repo to be the same as the target repo. It would be cool if it inspected my configure repo or assumed that I was trying to do a pull request from whatever I have configured as origin to upstream and allow configuration if the user deviates beyond that convention.

    Does it allow looking for a target repo by referencing the given remote?

    stash pull-request origin/master upstream/master @reviewer

  5. Jeremy Edgell reporter

    @checketts I didn't think to look at that - nice catch. It did perform a pull request from local to remote, but then again we're vicious pushers, so everything lined up well enough that the pull request went through and looked right. I also did that at midnight thirty last night, so I will check again this evening. I suspect we're polluting this particular ticket, so I'll open a bug on my repo and cc you there.

  6. Seb Ruiz Account Deactivated

    Why not use the Stash rest api to find the repository's parent and create a pull request there?

  7. Clint Checketts

    Yes, definitely using the repository's parent for the vast majority of pull requests would be ideal.

    I was merely brainstorming that we'd need to list various repositories when defining a pull request, but by default I'd love if the CLI could deduce it.

  8. Seb Ruiz Account Deactivated

    Certainly it could, by making a REST call back to Stash:

    seb@storm:dev/jira ‹master›$ curl -u sruiz -H "Accept: application/json" https://stash.atlassian.com/rest/api/1.0/users/sruiz/repos/jira/
    
    {
        "slug": "jira",
        "id": 260,
        "name": "jira",
        "scmId": "git",
        "state": "AVAILABLE",
        "statusMessage": "Available",
        "forkable": true,
        "origin": {
            "slug": "jira",
            "id": 81,
            "name": "jira",
            "scmId": "git",
            "link": {
                "url": "/projects/JIRA/repos/jira/browse",
                "rel": "self"
            }
        },
        "project": {
            "key": "~SRUIZ"
        }
    }
    

    (output trimmed).

    See the origin property of the repo.

  9. Log in to comment