summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 9f1918b..15aecf5 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -3211,6 +3211,28 @@ class ProjectFileManager(GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
)
return utils.response_content(result, streamed, action, chunk_size)
+ @cli.register_custom_action("ProjectFileManager", ("file_path", "ref"))
+ @exc.on_http_error(exc.GitlabListError)
+ def blame(self, file_path, ref, **kwargs):
+ """Return the content of a file for a commit.
+
+ Args:
+ file_path (str): Path of the file to retrieve
+ ref (str): Name of the branch, tag or commit
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabListError: If the server failed to perform the request
+
+ Returns:
+ list(blame): a list of commits/lines matching the file
+ """
+ file_path = file_path.replace("/", "%2F").replace(".", "%2E")
+ path = "%s/%s/blame" % (self.path, file_path)
+ query_data = {"ref": ref}
+ return self.gitlab.http_list(path, query_data, **kwargs)
+
class ProjectPipelineJob(RESTObject):
pass