| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ba2b60e commit f5b4a11
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,6 +362,10 @@ Delete a file:: | |||
| 362 | 362 | ||
| 363 | 363 | f.delete(commit_message='Delete testfile') | |
| 364 | 364 | ||
| 365 | + Get file blame:: | ||
| 366 | + | ||
| 367 | + b = project.files.blame(file_path='README.rst', ref='master') | ||
| 368 | + | ||
| 365 | 369 | Project tags | |
| 366 | 370 | ============ | |
| 367 | 371 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3211,6 +3211,28 @@ def raw( | |||
| 3211 | 3211 | ) | |
| 3212 | 3212 | return utils.response_content(result, streamed, action, chunk_size) | |
| 3213 | 3213 | ||
| 3214 | + @cli.register_custom_action("ProjectFileManager", ("file_path", "ref")) | ||
| 3215 | + @exc.on_http_error(exc.GitlabListError) | ||
| 3216 | + def blame(self, file_path, ref, **kwargs): | ||
| 3217 | + """Return the content of a file for a commit. | ||
| 3218 | + | ||
| 3219 | + Args: | ||
| 3220 | + file_path (str): Path of the file to retrieve | ||
| 3221 | + ref (str): Name of the branch, tag or commit | ||
| 3222 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3223 | + | ||
| 3224 | + Raises: | ||
| 3225 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3226 | + GitlabListError: If the server failed to perform the request | ||
| 3227 | + | ||
| 3228 | + Returns: | ||
| 3229 | + list(blame): a list of commits/lines matching the file | ||
| 3230 | + """ | ||
| 3231 | + file_path = file_path.replace("/", "%2F").replace(".", "%2E") | ||
| 3232 | + path = "%s/%s/blame" % (self.path, file_path) | ||
| 3233 | + query_data = {"ref": ref} | ||
| 3234 | + return self.gitlab.http_list(path, query_data, **kwargs) | ||
| 3235 | + | ||
| 3214 | 3236 | ||
| 3215 | 3237 | class ProjectPipelineJob(RESTObject): | |
| 3216 | 3238 | pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -423,6 +423,8 @@ | |||
| 423 | 423 | # object method | |
| 424 | 424 | assert readme.decode().decode() == "Initial content" | |
| 425 | 425 | ||
| 426 | + blame = admin_project.files.blame(file_path="README.rst", ref="master") | ||
| 427 | + | ||
| 426 | 428 | data = { | |
| 427 | 429 | "branch": "master", | |
| 428 | 430 | "commit_message": "blah blah blah", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments