| 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 2962235da84e6c0a1d6f71824ea7694e6a08883b..20d3ce63ae702233310ccc3bba8e88ff4cd374eb 100644
|
| --- a/chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| +++ b/chrome/common/extensions/docs/server2/gitiles_file_system.py
|
| @@ -49,6 +49,10 @@ def _CreateStatInfo(json_data):
|
| dict((e['name'], e['id']) for e in tree['entries']))
|
|
|
|
|
| +def _CreateIdentityFromCommit(commit):
|
| + return '%s/%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT, commit)
|
| +
|
| +
|
| class GitilesFileSystem(FileSystem):
|
| '''Class to fetch filesystem data from the Chromium project's gitiles
|
| service.
|
| @@ -232,12 +236,21 @@ class GitilesFileSystem(FileSystem):
|
| fetch_future = self._FetchAsync(ToDirectory(dir_) + _JSON_FORMAT)
|
| return self._ResolveFetchContent(path, fetch_future).Then(stat)
|
|
|
| - def GetIdentity(self):
|
| - # NOTE: Do not use commit information to create the string identity.
|
| - # Doing so will mess up caching.
|
| - if self._commit is None and self._branch != 'master':
|
| + def GetStableIdentity(self):
|
| + '''The stable identity is always the same for GitilesFileSystems designated
|
| + to master, even if they are pinned to a specific commit'''
|
| + if self._branch == 'master':
|
| + str_id = '%s/%s/master' % (GITILES_BASE, GITILES_SRC_ROOT)
|
| + elif self._commit is not None:
|
| + str_id = _CreateIdentityFromCommit(self._commit)
|
| + else:
|
| str_id = '%s/%s/%s/%s' % (
|
| GITILES_BASE, GITILES_SRC_ROOT, GITILES_BRANCHES_PATH, self._branch)
|
| - else:
|
| - str_id = '%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT)
|
| return '@'.join((self.__class__.__name__, StringIdentity(str_id)))
|
| +
|
| + def GetUnstableIdentity(self):
|
| + '''The unstable identity always tracks the commit ID if set.'''
|
| + if self._commit is not None:
|
| + return '@'.join((self.__class__.__name__, StringIdentity(
|
| + _CreateIdentityFromCommit(self._commit))))
|
| + return self.GetStableIdentity()
|
|
|