Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource fails when MR with deleted source branch exists #9

Closed
detached opened this issue May 12, 2017 · 3 comments
Closed

Resource fails when MR with deleted source branch exists #9

detached opened this issue May 12, 2017 · 3 comments

Comments

@detached
Copy link

When in Gitlab a merge request is open but its source branch was deleted, the Gitlab API returns the following json:

{
        "id": 105,
        "iid": 47,
        "project_id": 21,
        "title": "Feature/xxxxx",
        "description": "xxxxx",
        "state": "opened",
        "created_at": "2017-05-03T13:55:50.786Z",
        "updated_at": "2017-05-08T09:36:02.817Z",
        "target_branch": "development",
        "source_branch": "feature/xxxx",
        "upvotes": 0,
        "downvotes": 0,
        "author": {
            "name": "xxxxxx",
            "username": "xxxxx",
            "id": 8,
            "state": "active",
            "avatar_url": "xxxxx",
            "web_url": "xxxxx"
        },
        "assignee": {
            "name": "xxxxxx",
            "username": "xxxxx",
            "id": 8,
            "state": "active",
            "avatar_url": "xxxxx",
            "web_url": "xxxxx"
        },
        "source_project_id": 21,
        "target_project_id": 21,
        "labels": [

        ],
        "work_in_progress": false,
        "milestone": null,
        "merge_when_build_succeeds": false,
        "merge_status": "unchecked",
        "sha": null,
        "merge_commit_sha": null,
        "subscribed": false,
        "user_notes_count": 2,
        "should_remove_source_branch": null,
        "force_remove_source_branch": false,
        "web_url": "http://gitlab.company.de/proj/path/merge_requests/47"
    }

Because the sha value is null the resource is failing in the check step and no merge request can be build.

resource script '/opt/resource/check []' failed: exit status 128

stderr:
Already up-to-date.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3440  100  3440    0     0  19355      0 --:--:-- --:--:-- --:--:-- 19545
fatal: ambiguous argument 'null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

The problematic line is https://github.com/swisscom/gitlab-merge-request-resource/blob/master/scripts/check#L72

Maybe it would be good to check for this case and just skip this merge request with a warning message.

PS:
Thank you for the plugin, it works great! 👍

@cloudlena
Copy link
Contributor

Thanks, @detached! I created #10. Please let me know if you think that would solve your problem.

@cloudlena
Copy link
Contributor

Should be fixed by #11. If so, please close.

@detached
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants