Add username field to Merge hook JSON to be consistent with other hooks

Observed in actual requests, but is also shown in the examples on https://gitlab.com/help/web_hooks/web_hooks

Most of the hook messages contain a "user" block which contains both the user's real name and username, for example in the merge hook:

{
  "object_kind": "merge_request",
  "user": {
    "name": "Administrator",
    "username": "root",
    "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
  },
  "object_attributes": {
    "id": 99,
    ...
}

In the push hook, we just have a user_name field:

{
  "object_kind": "push",
  "before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
  "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
  "ref": "refs/heads/master",
  "user_id": 4,
  "user_name": "John Smith",
  "user_email": "john@example.com",
  "project_id": 15,
  ...
}

user_name shows the real name. The account username is not present in push messages at all.

For my project, I'd like to show the username in IRC messages from pushes and merge requests, but currently I have to be inconsistent or always use the real name.

Also, for the sake of consistency, it makes more sense to use the user block in all hook messages. I recognise that changing this would break others implementations at this point, but I'd like the user block to be added to the push hook, or at least a username field.

Edited Nov 24, 2022 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading