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 ahead, print with symbol
if g.repo.ahead > 0 { 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 behind, print with symbol
if g.repo.behind > 0 { 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 != "" { 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 == "" { } 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, "~")) staging := g.repo.staging.string(g.props.getString(LocalStagingIcon, "\uF046"))
working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "#")) working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "\uF044"))
fmt.Fprint(buffer, staging) fmt.Fprint(buffer, staging)
if staging != "" && working != "" { if staging != "" && working != "" {
fmt.Fprint(buffer, g.props.getString(StatusSeparatorIcon, " |")) fmt.Fprint(buffer, g.props.getString(StatusSeparatorIcon, " |"))
} }
fmt.Fprint(buffer, working) fmt.Fprint(buffer, working)
if g.props.getBool(DisplayStashCount, false) && g.repo.stashCount != "" { 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() return buffer.String()
} }
@ -153,15 +153,15 @@ func (g *git) getUpstreamSymbol() string {
upstream := upstreamRegex.ReplaceAllString(g.repo.upstream, "") upstream := upstreamRegex.ReplaceAllString(g.repo.upstream, "")
url := g.getGitCommandOutput("remote", "get-url", upstream) url := g.getGitCommandOutput("remote", "get-url", upstream)
if strings.Contains(url, "github") { if strings.Contains(url, "github") {
return g.props.getString(GithubIcon, "GITHUB") return g.props.getString(GithubIcon, "\uF408 ")
} }
if strings.Contains(url, "gitlab") { if strings.Contains(url, "gitlab") {
return g.props.getString(GitlabIcon, "GITLAB") return g.props.getString(GitlabIcon, "\uF296 ")
} }
if strings.Contains(url, "bitbucket") { 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() { func (g *git) setGitStatus() {
@ -187,7 +187,7 @@ func (g *git) getGitCommandOutput(args ...string) string {
} }
func (g *git) getGitHEADContext(ref string) string { func (g *git) getGitHEADContext(ref string) string {
branchIcon := g.props.getString(BranchIcon, "BRANCH:") branchIcon := g.props.getString(BranchIcon, "\uE0A0")
if ref == "" { if ref == "" {
ref = g.getPrettyHEADName() ref = g.getPrettyHEADName()
} else { } else {
@ -199,7 +199,7 @@ func (g *git) getGitHEADContext(ref string) string {
onto := g.getGitRefFileSymbolicName("rebase-merge/onto") onto := g.getGitRefFileSymbolicName("rebase-merge/onto")
step := g.getGitFileContents("rebase-merge/msgnum") step := g.getGitFileContents("rebase-merge/msgnum")
total := g.getGitFileContents("rebase-merge/end") 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) 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") { if g.hasGitFolder("rebase-apply") {
@ -207,19 +207,19 @@ func (g *git) getGitHEADContext(ref string) string {
origin := strings.Replace(head, "refs/heads/", "", 1) origin := strings.Replace(head, "refs/heads/", "", 1)
step := g.getGitFileContents("rebase-apply/next") step := g.getGitFileContents("rebase-apply/next")
total := g.getGitFileContents("rebase-apply/last") 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) return fmt.Sprintf("%s%s%s (%s/%s) at %s", icon, branchIcon, origin, step, total, ref)
} }
// merge // merge
if g.hasGitFile("MERGE_HEAD") { if g.hasGitFile("MERGE_HEAD") {
mergeHEAD := g.getGitRefFileSymbolicName("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) return fmt.Sprintf("%s%s%s into %s", icon, branchIcon, mergeHEAD, ref)
} }
// cherry-pick // cherry-pick
if g.hasGitFile("CHERRY_PICK_HEAD") { if g.hasGitFile("CHERRY_PICK_HEAD") {
sha := g.getGitRefFileSymbolicName("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 fmt.Sprintf("%s%s onto %s", icon, sha, ref)
} }
return ref return ref
@ -249,11 +249,11 @@ func (g *git) getPrettyHEADName() string {
// check for tag // check for tag
ref := g.getGitCommandOutput("describe", "--tags", "--exact-match") ref := g.getGitCommandOutput("describe", "--tags", "--exact-match")
if ref != "" { 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 // fallback to commit
ref = g.getGitCommandOutput("rev-parse", "--short", "HEAD") 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 { 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) { func TestGetGitDetachedCommitHash(t *testing.T) {
want := "COMMIT:lalasha1" want := "\uf417lalasha1"
context := &detachedContext{ context := &detachedContext{
currentCommit: "lalasha1", currentCommit: "lalasha1",
} }
@ -96,7 +96,7 @@ func TestGetGitDetachedCommitHash(t *testing.T) {
} }
func TestGetGitHEADContextTagName(t *testing.T) { func TestGetGitHEADContextTagName(t *testing.T) {
want := "TAG:lalasha1" want := "\uf412lalasha1"
context := &detachedContext{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
tagName: "lalasha1", tagName: "lalasha1",
@ -107,7 +107,7 @@ func TestGetGitHEADContextTagName(t *testing.T) {
} }
func TestGetGitHEADContextRebaseMerge(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{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
rebase: "true", rebase: "true",
@ -123,7 +123,7 @@ func TestGetGitHEADContextRebaseMerge(t *testing.T) {
} }
func TestGetGitHEADContextRebaseApply(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{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
rebase: "true", rebase: "true",
@ -138,7 +138,7 @@ func TestGetGitHEADContextRebaseApply(t *testing.T) {
} }
func TestGetGitHEADContextRebaseUnknown(t *testing.T) { func TestGetGitHEADContextRebaseUnknown(t *testing.T) {
want := "COMMIT:whatever" want := "\uf417whatever"
context := &detachedContext{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
rebase: "true", rebase: "true",
@ -149,7 +149,7 @@ func TestGetGitHEADContextRebaseUnknown(t *testing.T) {
} }
func TestGetGitHEADContextCherryPickOnBranch(t *testing.T) { func TestGetGitHEADContextCherryPickOnBranch(t *testing.T) {
want := "CHERRY PICK:pickme onto BRANCH:main" want := "\ue29b pickme onto \ue0a0main"
context := &detachedContext{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
branchName: "main", branchName: "main",
@ -162,7 +162,7 @@ func TestGetGitHEADContextCherryPickOnBranch(t *testing.T) {
} }
func TestGetGitHEADContextCherryPickOnTag(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{ context := &detachedContext{
currentCommit: "whatever", currentCommit: "whatever",
tagName: "v3.4.6", tagName: "v3.4.6",
@ -175,7 +175,7 @@ func TestGetGitHEADContextCherryPickOnTag(t *testing.T) {
} }
func TestGetGitHEADContextMerge(t *testing.T) { func TestGetGitHEADContextMerge(t *testing.T) {
want := "MERGING:BRANCH:feat into BRANCH:main" want := "\ue727 \ue0a0feat into \ue0a0main"
context := &detachedContext{ context := &detachedContext{
merge: true, merge: true,
mergeHEAD: "feat", mergeHEAD: "feat",
@ -186,7 +186,7 @@ func TestGetGitHEADContextMerge(t *testing.T) {
} }
func TestGetGitHEADContextMergeTag(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{ context := &detachedContext{
tagName: "v3.4.6", tagName: "v3.4.6",
merge: true, merge: true,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,13 +32,6 @@
"style": "plain", "style": "plain",
"foreground": "#B8B80A", "foreground": "#B8B80A",
"properties": { "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:</>" "prefix": "<#ffffff>on git:</>"
} }
} }

View file

@ -46,25 +46,8 @@
"foreground": "#193549", "foreground": "#193549",
"background": "#fffb38", "background": "#fffb38",
"properties": { "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, "display_stash_count": true,
"stash_count_icon": "\uF692 ", "display_upstream_icon": true
"merge_icon": "\uE726 ",
"display_upstream_icon": true,
"github_icon": "\uE709",
"bitbucket_icon": "\uE703",
"gitlab_icon": "\uE296",
"git_icon": "\uE702"
} }
}, },
{ {
@ -75,9 +58,6 @@
"background": "#f36943", "background": "#f36943",
"properties": { "properties": {
"battery_icon": "", "battery_icon": "",
"discharging_icon": "\uE231 ",
"charging_icon": "\uE234 ",
"charged_icon": "\uE22F ",
"color_background": true, "color_background": true,
"charged_color": "#4caf50", "charged_color": "#4caf50",
"charging_color": "#40c4ff", "charging_color": "#40c4ff",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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