Skip to content

Commit

Permalink
Merge pull request #727 from randy3k/randy3k/tags
Browse files Browse the repository at this point in the history
Enhancement: limit of items in tags dashboard
  • Loading branch information
randy3k committed Aug 12, 2017
2 parents ff66439 + 114628b commit 32463a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions GitSavvy.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
*/
"show_remotes_in_tags_dashboard": false,

/*
Limit the number of tags listed in the tags dashboard.
*/
// "max_items_in_tags_dashboard": 10

/*
When set to `true`, GitSavvy will offer to set the upstream on `git: push`
when tracking branch is not configured.
Expand Down
12 changes: 7 additions & 5 deletions core/interfaces/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def pre_render(self):
if self.show_remotes is None:
savvy_settings = sublime.load_settings("GitSavvy.sublime-settings")
self.show_remotes = savvy_settings.get("show_remotes_in_tags_dashboard")
self.max_items = savvy_settings.get("max_items_in_tags_dashboard", None)

self.local_tags = self.get_tags(reverse=True)
if not self.remotes and self.show_remotes:
Expand Down Expand Up @@ -110,7 +111,7 @@ def render_local_tags(self):

return "\n".join(
" {} {}".format(self.get_short_hash(tag.sha), tag.tag)
for tag in self.local_tags
for tag in self.local_tags[0:self.max_items]
)

@ui.partial("remote_tags")
Expand Down Expand Up @@ -147,10 +148,11 @@ def render_help(self):
def get_remote_tags_list(self, remote, remote_name):
if "tags" in remote:
if remote["tags"]:
msg = "\n".join(
" {} {}".format(self.get_short_hash(tag.sha), tag.tag)
for tag in remote["tags"] if tag.tag[-3:] != "^{}"
)
tags_list = [tag for tag in remote["tags"] if tag.tag[-3:] != "^{}"]
tags_list = tags_list[0:self.max_items]

msg = "\n".join(" {} {}".format(
self.get_short_hash(tag.sha), tag.tag) for tag in tags_list)
else:
msg = NO_REMOTE_TAGS_MESSAGE

Expand Down

0 comments on commit 32463a7

Please sign in to comment.