| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8ce8218 commit 45adb6e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1448,6 +1448,11 @@ def Tag(self, id=None, **kwargs): | |||
| 1448 | 1448 | **kwargs) | |
| 1449 | 1449 | ||
| 1450 | 1450 | def tree(self, path='', ref_name='', **kwargs): | |
| 1451 | + warnings.warn("`tree` is deprecated, use `repository_tree` instead", | ||
| 1452 | + DeprecationWarning) | ||
| 1453 | + return self.repository_tree(path, ref_name, **kwargs) | ||
| 1454 | + | ||
| 1455 | + def repository_tree(self, path='', ref_name='', **kwargs): | ||
| 1451 | 1456 | """Return a list of files in the repository. | |
| 1452 | 1457 | ||
| 1453 | 1458 | Args: | |
@@ -1474,6 +1479,11 @@ def tree(self, path='', ref_name='', **kwargs): | |||
| 1474 | 1479 | return r.json() | |
| 1475 | 1480 | ||
| 1476 | 1481 | def blob(self, sha, filepath, **kwargs): | |
| 1482 | + warnings.warn("`blob` is deprecated, use `repository_blob` instead", | ||
| 1483 | + DeprecationWarning) | ||
| 1484 | + return self.repository_blob(sha, filepath, **kwargs) | ||
| 1485 | + | ||
| 1486 | + def repository_blob(self, sha, filepath, **kwargs): | ||
| 1477 | 1487 | """Return the content of a file for a commit. | |
| 1478 | 1488 | ||
| 1479 | 1489 | Args: | |
@@ -1493,7 +1503,7 @@ def blob(self, sha, filepath, **kwargs): | |||
| 1493 | 1503 | raise_error_from_response(r, GitlabGetError) | |
| 1494 | 1504 | return r.content | |
| 1495 | 1505 | ||
| 1496 | - def raw_blob(self, sha, **kwargs): | ||
| 1506 | + def repository_raw_blob(self, sha, **kwargs): | ||
| 1497 | 1507 | """Returns the raw file contents for a blob by blob SHA. | |
| 1498 | 1508 | ||
| 1499 | 1509 | Args: | |
@@ -1511,7 +1521,7 @@ def raw_blob(self, sha, **kwargs): | |||
| 1511 | 1521 | raise_error_from_response(r, GitlabGetError) | |
| 1512 | 1522 | return r.content | |
| 1513 | 1523 | ||
| 1514 | - def compare(self, from_, to, **kwargs): | ||
| 1524 | + def repository_compare(self, from_, to, **kwargs): | ||
| 1515 | 1525 | """Returns a diff between two branches/commits. | |
| 1516 | 1526 | ||
| 1517 | 1527 | Args: | |
@@ -1531,7 +1541,7 @@ def compare(self, from_, to, **kwargs): | |||
| 1531 | 1541 | raise_error_from_response(r, GitlabGetError) | |
| 1532 | 1542 | return r.json() | |
| 1533 | 1543 | ||
| 1534 | - def contributors(self): | ||
| 1544 | + def repository_contributors(self): | ||
| 1535 | 1545 | """Returns a list of contributors for the project. | |
| 1536 | 1546 | ||
| 1537 | 1547 | Returns: | |
@@ -1580,20 +1590,29 @@ def create_file(self, path, branch, content, message, **kwargs): | |||
| 1580 | 1590 | GitlabConnectionError: If the server cannot be reached. | |
| 1581 | 1591 | GitlabCreateError: If the server fails to perform the request. | |
| 1582 | 1592 | """ | |
| 1593 | + warnings.warn("`create_file` is deprecated, " | ||
| 1594 | + "use `files.create()` instead", | ||
| 1595 | + DeprecationWarning) | ||
| 1583 | 1596 | url = "/projects/%s/repository/files" % self.id | |
| 1584 | 1597 | url += ("?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % | |
| 1585 | 1598 | (path, branch, content, message)) | |
| 1586 | 1599 | r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs) | |
| 1587 | 1600 | raise_error_from_response(r, GitlabCreateError, 201) | |
| 1588 | 1601 | ||
| 1589 | 1602 | def update_file(self, path, branch, content, message, **kwargs): | |
| 1603 | + warnings.warn("`update_file` is deprecated, " | ||
| 1604 | + "use `files.update()` instead", | ||
| 1605 | + DeprecationWarning) | ||
| 1590 | 1606 | url = "/projects/%s/repository/files" % self.id | |
| 1591 | 1607 | url += ("?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % | |
| 1592 | 1608 | (path, branch, content, message)) | |
| 1593 | 1609 | r = self.gitlab._raw_put(url, data=None, content_type=None, **kwargs) | |
| 1594 | 1610 | raise_error_from_response(r, GitlabUpdateError) | |
| 1595 | 1611 | ||
| 1596 | 1612 | def delete_file(self, path, branch, message, **kwargs): | |
| 1613 | + warnings.warn("`delete_file` is deprecated, " | ||
| 1614 | + "use `files.delete()` instead", | ||
| 1615 | + DeprecationWarning) | ||
| 1597 | 1616 | url = "/projects/%s/repository/files" % self.id | |
| 1598 | 1617 | url += ("?file_path=%s&branch_name=%s&commit_message=%s" % | |
| 1599 | 1618 | (path, branch, message)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | import base64 | |
| 2 | + import time | ||
| 2 | 3 | ||
| 3 | 4 | import gitlab | |
| 4 | 5 | ||
@@ -135,6 +136,7 @@ | |||
| 135 | 136 | 'commit_message': 'Initial commit'}) | |
| 136 | 137 | readme = admin_project.files.get(file_path='README', ref='master') | |
| 137 | 138 | readme.content = base64.b64encode("Improved README") | |
| 139 | + time.sleep(2) | ||
| 138 | 140 | readme.save(branch_name="master", commit_message="new commit") | |
| 139 | 141 | readme.delete(commit_message="Removing README") | |
| 140 | 142 | ||
@@ -145,10 +147,10 @@ | |||
| 145 | 147 | readme = admin_project.files.get(file_path='README.rst', ref='master') | |
| 146 | 148 | assert(readme.decode() == 'Initial content') | |
| 147 | 149 | ||
| 148 | - tree = admin_project.tree() | ||
| 150 | + tree = admin_project.repository_tree() | ||
| 149 | 151 | assert(len(tree) == 1) | |
| 150 | 152 | assert(tree[0]['name'] == 'README.rst') | |
| 151 | - blob = admin_project.blob('master', 'README.rst') | ||
| 153 | + blob = admin_project.repository_blob('master', 'README.rst') | ||
| 152 | 154 | assert(blob == 'Initial content') | |
| 153 | 155 | archive1 = admin_project.archive() | |
| 154 | 156 | archive2 = admin_project.archive('master') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments