added Branches button into header
This commit is contained in:
@@ -314,7 +314,7 @@ def test_header_shows_head_upstream_and_the_links_of_the_selected_kind():
|
||||
assert "up to date" in header(view)
|
||||
st.branch_refs[1] = REFS[1]
|
||||
branches.render_branches(view, st)
|
||||
for link in ("checkout", "pull", "push", "fetch", "delete_branch", "files", "commits", "help"):
|
||||
for link in ("checkout", "pull", "push", "fetch", "delete_branch", "files", "commits", "branches", "help"):
|
||||
assert f'href="{link}"' in text
|
||||
assert 'href="checkout_detached"' not in text
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ def test_help_popup_lists_every_key():
|
||||
assert "next / previous change" in html and "open the real file at this line" in html
|
||||
# working-tree mode: nothing dimmed, every single-action row is a link
|
||||
assert 'class="dim"' not in html and "uncommitted only" not in html
|
||||
assert 'href="discard"' in html and 'href="files"' in html and 'href="close"' in html
|
||||
assert 'href="discard"' in html and 'href="files"' in html and 'href="branches"' in html and 'href="close"' in html
|
||||
# rows covering two actions stay plain text
|
||||
assert 'href="next_change"' not in html and 'href="stage"' not in html
|
||||
# the popup does not list the key that opens it
|
||||
|
||||
@@ -715,8 +715,7 @@ def _colour_runs(
|
||||
return runs
|
||||
|
||||
|
||||
def _finish(view: sublime.View, st: ViewState, mode: str, name: str, header: str,
|
||||
key: Callable[[ViewState], Any] = fingerprint) -> None:
|
||||
def _finish(view: sublime.View, st: ViewState, mode: str, name: str, header: str, key: Callable[[ViewState], Any] = fingerprint) -> None:
|
||||
"""Mode, header, tab name, status bar and bookkeeping shared by every render: what was drawn is settled here
|
||||
|
||||
`key` is the mode's fingerprint, the branches view's own one there
|
||||
@@ -819,7 +818,9 @@ def _commit_parts(st: ViewState) -> List[str]:
|
||||
parts.append(f'<span class="when">{html.escape(info.date)}</span>')
|
||||
# binary files add nothing to the line totals but still count toward the file total
|
||||
stat = git.worktree_stats(st.files)
|
||||
parts.append(f"{file_count(stat.files)} changed" f' <span class="del">-{stat.deletions}</span> <span class="ins">+{stat.insertions}</span>')
|
||||
parts.append(
|
||||
f"{file_count(stat.files)} changed" f' <span class="del">-{stat.deletions}</span> <span class="ins">+{stat.insertions}</span>'
|
||||
)
|
||||
# the subject, plus the body's first line
|
||||
if info:
|
||||
message = html.escape(info.subject)
|
||||
@@ -862,7 +863,12 @@ def header_html(st: ViewState, ins: Optional[int], dele: Optional[int]) -> str:
|
||||
|
||||
def header_frame(summary: str, title: str, actions: Sequence[str]) -> str:
|
||||
"""The header's body: the summary line, then the title with `actions` and the links every view has"""
|
||||
links = list(actions) + ['<a href="files">Files</a>', '<a href="commits">Commits</a>', '<a href="help" title="keys">?</a>']
|
||||
links = list(actions) + [
|
||||
'<a href="files">Files</a>',
|
||||
'<a href="commits">Commits</a>',
|
||||
'<a href="branches">Branches</a>',
|
||||
'<a href="help" title="keys">?</a>',
|
||||
]
|
||||
return (
|
||||
f'<body id="vdiff-header"><style>{HEADER_CSS}</style>{summary}'
|
||||
f'<div>{title}<span class="actions">{"".join(links)}</span></div></body>'
|
||||
|
||||
Reference in New Issue
Block a user