Skip to content

Commit 26b8a3d

Browse files
committed
Cache branch descriptions in the store
1 parent e111603 commit 26b8a3d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

core/git_mixins/branches.py

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def fetch_branch_description_subjects(self):
139139

140140
branch_name, description = match.group(1), match.group(2)
141141
rv[branch_name] = description
142+
store.update_state(self.repo_path, {"descriptions": rv})
142143
return rv
143144

144145
def _parse_branch_line(self, line):

core/interfaces/branch.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def refresh_view_state(self):
166166
'git_root': self.short_repo_path,
167167
'branches': state.get("branches", []),
168168
'recent_commits': state.get("recent_commits", []),
169+
'descriptions': state.get("descriptions", {}),
169170
'show_help': not self.view.settings().get("git_savvy.help_hidden"),
170171
})
171172

@@ -221,11 +222,14 @@ def on_status_update(self, _repo_path, state):
221222
new_state = {}
222223
new_state["branches"] = state.get("branches")
223224
new_state["recent_commits"] = state.get("recent_commits")
225+
new_state["descriptions"] = state.get("descriptions")
224226
self.update_state(new_state, then=self.just_render)
225227

226228
def on_create(self):
227229
self._unsubscribe = store.subscribe(
228-
self.repo_path, {"status", "branches", "recent_commits"}, self.on_status_update
230+
self.repo_path,
231+
{"status", "branches", "recent_commits", "descriptions"},
232+
self.on_status_update
229233
)
230234

231235
def on_close(self):

core/store.py

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"short_hash_length": int,
3333
"stashes": List[Stash],
3434
"recent_commits": List[Commit],
35+
"descriptions": Dict[str, str],
3536
},
3637
total=False
3738
)

tests/test_fetch_branch_descriptions.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from GitSavvy.tests.mockito import when
55
from GitSavvy.tests.parameterized import parameterized as p
66

7-
from GitSavvy.core.git_mixins.branches import BranchesMixin
7+
from GitSavvy.core.git_command import GitCommand
88

99

1010
examples = [
@@ -32,6 +32,7 @@
3232
class TestFetchBranchDescriptions(DeferrableTestCase):
3333
@p.expand(examples)
3434
def test_description_subjects(self, git_output, expected):
35-
test = BranchesMixin()
35+
test = GitCommand()
36+
when(test).get_repo_path().thenReturn("probably/here")
3637
when(test, strict=False).git("config", ...).thenReturn(git_output)
3738
self.assertEqual(expected, test.fetch_branch_description_subjects())

0 commit comments

Comments
 (0)