refactor: replace git icons

This commit is contained in:
Jan De Dobbeleer 2020-10-16 13:28:54 +02:00 committed by Jan De Dobbeleer
parent db818b5fa4
commit dd86c486dd
18 changed files with 38 additions and 166 deletions

View file

@ -119,26 +119,26 @@ func (g *git) string() string {
}
// if ahead, print with symbol
if g.repo.ahead > 0 {
fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchAheadIcon, "+"), g.repo.ahead)
fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchAheadIcon, "\uF176"), g.repo.ahead)
}
// if behind, print with symbol
if g.repo.behind > 0 {
fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchBehindIcon, "-"), g.repo.behind)
fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchBehindIcon, "\uF175"), g.repo.behind)
}
if g.repo.behind == 0 && g.repo.ahead == 0 && g.repo.upstream != "" {
fmt.Fprintf(buffer, " %s", g.props.getString(BranchIdenticalIcon, "="))
fmt.Fprintf(buffer, " %s", g.props.getString(BranchIdenticalIcon, "\uF0C9"))
} else if g.repo.upstream == "" {
fmt.Fprintf(buffer, " %s", g.props.getString(BranchGoneIcon, "!="))
fmt.Fprintf(buffer, " %s", g.props.getString(BranchGoneIcon, "\u2262"))
}
staging := g.repo.staging.string(g.props.getString(LocalStagingIcon, "~"))
working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "#"))
staging := g.repo.staging.string(g.props.getString(LocalStagingIcon, "\uF046"))
working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "\uF044"))
fmt.Fprint(buffer, staging)
if staging != "" && working != "" {
fmt.Fprint(buffer, g.props.getString(StatusSeparatorIcon, " |"))
}
fmt.Fprint(buffer, working)
if g.props.getBool(DisplayStashCount, false) && g.repo.stashCount != "" {
fmt.Fprintf(buffer, " %s%s", g.props.getString(StashCountIcon, ""), g.repo.stashCount)
fmt.Fprintf(buffer, " %s%s", g.props.getString(StashCountIcon, "\uF692"), g.repo.stashCount)
}
return buffer.String()
}
@ -153,15 +153,15 @@ func (g *git) getUpstreamSymbol() string {
upstream := upstreamRegex.ReplaceAllString(g.repo.upstream, "")
url := g.getGitCommandOutput("remote", "get-url", upstream)
if strings.Contains(url, "github") {
return g.props.getString(GithubIcon, "GITHUB")
return g.props.getString(GithubIcon, "\uF408 ")
}
if strings.Contains(url, "gitlab") {
return g.props.getString(GitlabIcon, "GITLAB")
return g.props.getString(GitlabIcon, "\uF296 ")
}
if strings.Contains(url, "bitbucket") {
return g.props.getString(BitbucketIcon, "BITBUCKET")
return g.props.getString(BitbucketIcon, "\uF171 ")
}
return g.props.getString(GitIcon, "GIT")
return g.props.getString(GitIcon, "\uE5FB ")
}
func (g *git) setGitStatus() {
@ -187,7 +187,7 @@ func (g *git) getGitCommandOutput(args ...string) string {
}
func (g *git) getGitHEADContext(ref string) string {
branchIcon := g.props.getString(BranchIcon, "BRANCH:")
branchIcon := g.props.getString(BranchIcon, "\uE0A0")
if ref == "" {
ref = g.getPrettyHEADName()
} else {
@ -199,7 +199,7 @@ func (g *git) getGitHEADContext(ref string) string {
onto := g.getGitRefFileSymbolicName("rebase-merge/onto")
step := g.getGitFileContents("rebase-merge/msgnum")
total := g.getGitFileContents("rebase-merge/end")
icon := g.props.getString(RebaseIcon, "REBASE:")
icon := g.props.getString(RebaseIcon, "\uE728 ")
return fmt.Sprintf("%s%s%s onto %s%s (%s/%s) at %s", icon, branchIcon, origin, branchIcon, onto, step, total, ref)
}
if g.hasGitFolder("rebase-apply") {
@ -207,19 +207,19 @@ func (g *git) getGitHEADContext(ref string) string {
origin := strings.Replace(head, "refs/heads/", "", 1)
step := g.getGitFileContents("rebase-apply/next")
total := g.getGitFileContents("rebase-apply/last")
icon := g.props.getString(RebaseIcon, "REBASING:")
icon := g.props.getString(RebaseIcon, "\uE728 ")
return fmt.Sprintf("%s%s%s (%s/%s) at %s", icon, branchIcon, origin, step, total, ref)
}
// merge
if g.hasGitFile("MERGE_HEAD") {
mergeHEAD := g.getGitRefFileSymbolicName("MERGE_HEAD")
icon := g.props.getString(MergeIcon, "MERGING:")
icon := g.props.getString(MergeIcon, "\uE727 ")
return fmt.Sprintf("%s%s%s into %s", icon, branchIcon, mergeHEAD, ref)
}
// cherry-pick
if g.hasGitFile("CHERRY_PICK_HEAD") {
sha := g.getGitRefFileSymbolicName("CHERRY_PICK_HEAD")
icon := g.props.getString(CherryPickIcon, "CHERRY PICK:")
icon := g.props.getString(CherryPickIcon, "\uE29B ")
return fmt.Sprintf("%s%s onto %s", icon, sha, ref)
}
return ref
@ -249,11 +249,11 @@ func (g *git) getPrettyHEADName() string {
// check for tag
ref := g.getGitCommandOutput("describe", "--tags", "--exact-match")
if ref != "" {
return fmt.Sprintf("%s%s", g.props.getString(TagIcon, "TAG:"), ref)
return fmt.Sprintf("%s%s", g.props.getString(TagIcon, "\uF412"), ref)
}
// fallback to commit
ref = g.getGitCommandOutput("rev-parse", "--short", "HEAD")
return fmt.Sprintf("%s%s", g.props.getString(CommitIcon, "COMMIT:"), ref)
return fmt.Sprintf("%s%s", g.props.getString(CommitIcon, "\uF417"), ref)
}
func (g *git) parseGitStats(output []string, working bool) *gitStatus {

View file

@ -86,7 +86,7 @@ func setupHEADContextEnv(context *detachedContext) *git {
}
func TestGetGitDetachedCommitHash(t *testing.T) {
want := "COMMIT:lalasha1"
want := "\uf417lalasha1"
context := &detachedContext{
currentCommit: "lalasha1",
}
@ -96,7 +96,7 @@ func TestGetGitDetachedCommitHash(t *testing.T) {
}
func TestGetGitHEADContextTagName(t *testing.T) {
want := "TAG:lalasha1"
want := "\uf412lalasha1"
context := &detachedContext{
currentCommit: "whatever",
tagName: "lalasha1",
@ -107,7 +107,7 @@ func TestGetGitHEADContextTagName(t *testing.T) {
}
func TestGetGitHEADContextRebaseMerge(t *testing.T) {
want := "REBASE:BRANCH:cool-feature-bro onto BRANCH:main (2/3) at COMMIT:whatever"
want := "\ue728 \ue0a0cool-feature-bro onto \ue0a0main (2/3) at \uf417whatever"
context := &detachedContext{
currentCommit: "whatever",
rebase: "true",
@ -123,7 +123,7 @@ func TestGetGitHEADContextRebaseMerge(t *testing.T) {
}
func TestGetGitHEADContextRebaseApply(t *testing.T) {
want := "REBASING:BRANCH:cool-feature-bro (2/3) at COMMIT:whatever"
want := "\ue728 \ue0a0cool-feature-bro (2/3) at \uf417whatever"
context := &detachedContext{
currentCommit: "whatever",
rebase: "true",
@ -138,7 +138,7 @@ func TestGetGitHEADContextRebaseApply(t *testing.T) {
}
func TestGetGitHEADContextRebaseUnknown(t *testing.T) {
want := "COMMIT:whatever"
want := "\uf417whatever"
context := &detachedContext{
currentCommit: "whatever",
rebase: "true",
@ -149,7 +149,7 @@ func TestGetGitHEADContextRebaseUnknown(t *testing.T) {
}
func TestGetGitHEADContextCherryPickOnBranch(t *testing.T) {
want := "CHERRY PICK:pickme onto BRANCH:main"
want := "\ue29b pickme onto \ue0a0main"
context := &detachedContext{
currentCommit: "whatever",
branchName: "main",
@ -162,7 +162,7 @@ func TestGetGitHEADContextCherryPickOnBranch(t *testing.T) {
}
func TestGetGitHEADContextCherryPickOnTag(t *testing.T) {
want := "CHERRY PICK:pickme onto TAG:v3.4.6"
want := "\ue29b pickme onto \uf412v3.4.6"
context := &detachedContext{
currentCommit: "whatever",
tagName: "v3.4.6",
@ -175,7 +175,7 @@ func TestGetGitHEADContextCherryPickOnTag(t *testing.T) {
}
func TestGetGitHEADContextMerge(t *testing.T) {
want := "MERGING:BRANCH:feat into BRANCH:main"
want := "\ue727 \ue0a0feat into \ue0a0main"
context := &detachedContext{
merge: true,
mergeHEAD: "feat",
@ -186,7 +186,7 @@ func TestGetGitHEADContextMerge(t *testing.T) {
}
func TestGetGitHEADContextMergeTag(t *testing.T) {
want := "MERGING:BRANCH:feat into TAG:v3.4.6"
want := "\ue727 \ue0a0feat into \uf412v3.4.6"
context := &detachedContext{
tagName: "v3.4.6",
merge: true,

View file

@ -40,16 +40,7 @@
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"background": "#95ffa4"
},
{
"type": "python",

View file

@ -52,16 +52,7 @@
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"background": "#95ffa4"
}
]
}

View file

@ -32,16 +32,7 @@
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"background": "#95ffa4"
},
{
"type": "python",

View file

@ -17,16 +17,7 @@
{
"type": "git",
"style": "plain",
"foreground": "#C2C206",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"foreground": "#C2C206"
},
{
"type": "root",

View file

@ -20,13 +20,6 @@
"style": "plain",
"foreground": "#ffffff",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": "<#CB4B16>[</>",
"postfix": "<#CB4B16>]</>"
}

View file

@ -34,14 +34,10 @@
"style": "plain",
"foreground": "#F3C267",
"properties": {
"branch_icon": "🚦 ",
"branch_icon": "\u1F6A6 ",
"display_status": true,
"branch_identical_icon": "✅",
"branch_ahead_icon": "",
"branch_behind_icon": "",
"branch_gone_icon": "❎",
"local_working_icon": "",
"local_staged_icon": ""
"branch_identical_icon": "\uF14A",
"branch_gone_icon": "\u274E"
}
},
{

View file

@ -46,13 +46,6 @@
"foreground": "#ffffff",
"background": "#007ACC",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": "<#ffffff></> ",
"postfix": " "
}

View file

@ -32,13 +32,6 @@
"style": "plain",
"foreground": "#B8B80A",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": "<#ffffff>on git:</>"
}
}

View file

@ -46,25 +46,8 @@
"foreground": "#193549",
"background": "#fffb38",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"rebase_icon": " ",
"cherry_pick_icon": " ",
"detached_icon": " ",
"tag_icon": "笠",
"display_stash_count": true,
"stash_count_icon": "\uF692 ",
"merge_icon": "\uE726 ",
"display_upstream_icon": true,
"github_icon": "\uE709",
"bitbucket_icon": "\uE703",
"gitlab_icon": "\uE296",
"git_icon": "\uE702"
"display_upstream_icon": true
}
},
{
@ -75,9 +58,6 @@
"background": "#f36943",
"properties": {
"battery_icon": "",
"discharging_icon": "\uE231 ",
"charging_icon": "\uE234 ",
"charged_icon": "\uE22F ",
"color_background": true,
"charged_color": "#4caf50",
"charging_color": "#40c4ff",

View file

@ -26,13 +26,6 @@
"style": "plain",
"foreground": "#B80101",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": " <#F5F5F5>git:</>"
}
}

View file

@ -40,16 +40,7 @@
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"background": "#95ffa4"
},
{
"type": "python",

View file

@ -36,13 +36,6 @@
"foreground": "#D4E157",
"background": "#546E7A",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": "<#26C6DA> </>"
}
},

View file

@ -37,14 +37,7 @@
"style": "plain",
"foreground": "#FFE700",
"properties": {
"prefix": "",
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
"prefix": ""
}
},
{

View file

@ -33,16 +33,7 @@
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": ""
}
"background": "#95ffa4"
},
{
"type": "python",

View file

@ -36,13 +36,6 @@
"style": "plain",
"foreground": "#C1C106",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"prefix": "<#ffffff>git:</>"
}
},

View file

@ -30,7 +30,6 @@
"foreground": "#C678DD",
"properties": {
"prefix": "<#ffffff>on</> ",
"branch_icon": "",
"display_status": true
}
},