summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2019-04-17 15:26:19 +0200
committerRobert Speicher <rspeicher@gmail.com>2019-04-29 13:49:11 -0500
commit888e57130896fd3dc59f5e60dcaa06cbc2d27c7b (patch)
treeb8983f4e20c8098836a7e1943ed41586f8efde67
parent7ae2107d9ebca0adecc8a21cacd1bfb6e89ee3ab (diff)
downloadgitlab-ce-rs-commit-web_url.tar.gz
Expose web_url attribute in Commits APIrs-commit-web_url
This continues our emerging standard of including this attribute for resources that have web-accessible endpoints.
-rw-r--r--changelogs/unreleased/rs-commit-web_url.yml5
-rw-r--r--doc/api/commits.md15
-rw-r--r--lib/api/entities.rb4
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/commit/basic.json6
4 files changed, 23 insertions, 7 deletions
diff --git a/changelogs/unreleased/rs-commit-web_url.yml b/changelogs/unreleased/rs-commit-web_url.yml
new file mode 100644
index 00000000000..d78ad22a50a
--- /dev/null
+++ b/changelogs/unreleased/rs-commit-web_url.yml
@@ -0,0 +1,5 @@
+---
+title: Expose web_url attribute in Commits API
+merge_request: 27463
+author:
+type: added
diff --git a/doc/api/commits.md b/doc/api/commits.md
index 92f53c7b5e6..63692ff180a 100644
--- a/doc/api/commits.md
+++ b/doc/api/commits.md
@@ -40,7 +40,8 @@ Example response:
"message": "Replace sanitize with escape once",
"parent_ids": [
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
- ]
+ ],
+ "web_url": "https://gitlab.com/gitlab-org/gitlab-ce/commit/ed899a2f4b50b4370feeea94676502b42383c746"
},
{
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
@@ -54,7 +55,8 @@ Example response:
"message": "Sanitize for network graph",
"parent_ids": [
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
- ]
+ ],
+ "web_url": "https://gitlab.com/gitlab-org/gitlab-ce/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"
}
]
```
@@ -152,7 +154,8 @@ Example response:
"deletions": 2,
"total": 4
},
- "status": null
+ "status": null,
+ "web_url": "https://gitlab.com/gitlab-org/gitlab-ce/commit/ed899a2f4b50b4370feeea94676502b42383c746"
}
```
@@ -231,7 +234,8 @@ Example response:
"deletions": 10,
"total": 25
},
- "status": "running"
+ "status": "running",
+ "web_url": "https://gitlab.com/gitlab-org/gitlab-ce/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"
}
```
@@ -310,7 +314,8 @@ Example response:
"message": "Feature added\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n",
"parent_ids": [
"a738f717824ff53aebad8b090c1b79a14f2bd9e8"
- ]
+ ],
+ "web_url": "https://gitlab.com/gitlab-org/gitlab-ce/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"
}
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index ee8480122c4..8266b7d2392 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -393,6 +393,10 @@ module API
expose :safe_message, as: :message
expose :author_name, :author_email, :authored_date
expose :committer_name, :committer_email, :committed_date
+
+ expose :web_url do |commit|
+ Gitlab::Routing.url_helpers.project_commit_url(commit.project, commit)
+ end
end
class CommitStats < Grape::Entity
diff --git a/spec/fixtures/api/schemas/public_api/v4/commit/basic.json b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json
index 9d99628a286..da99e99c692 100644
--- a/spec/fixtures/api/schemas/public_api/v4/commit/basic.json
+++ b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json
@@ -12,7 +12,8 @@
"authored_date",
"committer_name",
"committer_email",
- "committed_date"
+ "committed_date",
+ "web_url"
],
"properties" : {
"id": { "type": ["string", "null"] },
@@ -32,6 +33,7 @@
"authored_date": { "type": "date" },
"committer_name": { "type": "string" },
"committer_email": { "type": "string" },
- "committed_date": { "type": "date" }
+ "committed_date": { "type": "date" },
+ "web_url": { "type": "string" }
}
}