| Index: chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| diff --git a/chrome/common/extensions/docs/server2/gitiles_file_system.py b/chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| index 5e2f86784a1b60dee722ef499514f234a2c92121..e903109a282893b0d14379b2be91fa21b756d8d6 100644
|
| --- a/chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| +++ b/chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| @@ -106,7 +106,8 @@ class GitilesFileSystem(FileSystem):
|
| # ...
|
| # }
|
| def list_dir(json_data):
|
| - return [e['name'] for e in _ParseGitilesJson(json_data)['entries']]
|
| + entries = _ParseGitilesJson(json_data)['entries']
|
| + return [e['name'] + ('/' if e['type'] == 'tree' else '') for e in entries]
|
|
|
| def fixup_url_format(path):
|
| # By default, Gitiles URLs display resources in HTML. To get resources
|
| @@ -135,8 +136,8 @@ class GitilesFileSystem(FileSystem):
|
| return Future(value=())
|
|
|
| @memoize
|
| - def GetCommitID(self):
|
| - '''Returns a future that resolves to the commit ID for this branch.
|
| + def _GetCommitInfo(self, key):
|
| + '''Retrieves a value from the Gitiles JSON commit view.
|
| '''
|
| # Commit information for a branch is obtained by appending '?format=JSON'
|
| # to the branch URL. Note that '<gitiles_url>/<branch>?format=JSON' is
|
| @@ -150,12 +151,24 @@ class GitilesFileSystem(FileSystem):
|
| # {
|
| # "commit": "8fd578e1a7b142cd10a4387861f05fb9459b69e2", # Commit ID.
|
| # "tree": "3ade65d8a91eadd009a6c9feea8f87db2c528a53", # Tree ID.
|
| + # # Previous Commit ID.
|
| + # "parents": ["a477c787fe847ae0482329f69b39ce0fde047359"],
|
| # "author": {...},
|
| # "committer": {...},
|
| # "message": <codereview message>,
|
| # ...
|
| # }
|
| - return content_future.Then(lambda json: _ParseGitilesJson(json)['commit'])
|
| + return content_future.Then(lambda json: _ParseGitilesJson(json)[key])
|
| +
|
| + def GetCommitID(self):
|
| + '''Returns a future that resolves to the commit ID for this branch.
|
| + '''
|
| + return self._GetCommitInfo('commit')
|
| +
|
| + def GetPreviousCommitID(self):
|
| + '''Returns a future that resolves to the previous commit ID for this branch.
|
| + '''
|
| + return self._GetCommitInfo('parents').Then(lambda parents: parents[0])
|
|
|
| def Stat(self, path):
|
| return self.StatAsync(path).Get()
|
|
|