gitlabhq/gitlabhq — pull request #7754 by Bugagazavr (2014-09-15 07:33:43+00:00)
Title: More information in merge request hook

**What does this MR do?**
This MR allow send more information about merge request via web hook: source project, target project and last commit.

Hook example:
```json
{
"object_kind": "merge_request",
"object_attributes": {
"id": 99,
"target_branch": "master",
"source_branch": "ms-viewport",
"source_project_id": 14,
"author_id": 51,
"assignee_id": 6,
"title": "MS-Viewport",
"created_at": "2013-12-03T17:23:34Z",
"updated_at": "2013-12-03T17:23:34Z",
"st_commits": null,
"st_diffs": null,
"milestone_id": null,
"state": "opened",
"merge_status": "unchecked",
"target_project_id": 14,
"iid": 1,
"description": "",
"source": {
"name": "awesome_project",
"ssh_url": "ssh://git@example.com/awesome_space/awesome_project.git",
"http_url": "http://example.com/awesome_space/awesome_project.git",
"visibility_level": 20,
"namespace": "awesome_space"
},
"target": {
"name": "awesome_project",
"ssh_url": "ssh://git@example.com/awesome_space/awesome_project.git",
"http_url": "http://example.com/awesome_space/awesome_project.git",
"visibility_level": 20,
"namespace": "awesome_space"
},
"last_commit": {
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/awesome_space/awesome_project/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
}
}
}
}
```

Was also affected by a piece of code responsible for the push event, as now has a certain common code base with Merga request

**Are there points in the code the reviewer needs to double check?**

- https://github.com/Bugagazavr/gitlabhq/blob/c3e05e3c7912440f64e65bbe9a5ae560c1193d35/app/models/merge_request.rb#L117-L121
- https://github.com/Bugagazavr/gitlabhq/blob/c3e05e3c7912440f64e65bbe9a5ae560c1193d35/app/services/git_push_service.rb#L154

**Why was this MR needed?**

- For many Continius Integration services, because now to get last commit sha, source remote ( if source is fork ) need work with API.
- GitLab doesn't have API to get last commits related with current PR, only project/branch.
- Also, I need this functionality to allow the drone to work with GitLab Merge Requests ( https://github.com/drone/drone/blob/exp/plugin/remote/gitlab/gitlab.go#L159-L162 )