diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-04-03 12:40:29 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-04-15 08:36:03 +0200 |
commit | 188773511e0c94a4ec338328865e824402ec8b00 (patch) | |
tree | 9c6c9b596c52d382c857071312743ff26ee70ae6 /pkg/commands/models/commit.go | |
parent | 62c5c32fbb0a44713933724e5c941ee1d42c2b27 (diff) |
Store commit.Status as an enum instead of a string
This is unrelated to the changes in this PR, but since we are doing the same
thing for the commit.Action field in the next commit, it makes sense to do it
for Status too for consistency. Modelling this as an enum feels more natural
than modelling it as a string, since there's a finite set of possible values.
And it saves a little bit of memory (not very much, since none of the strings
were heap-allocated, but still).
Diffstat (limited to 'pkg/commands/models/commit.go')
-rw-r--r-- | pkg/commands/models/commit.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/commands/models/commit.go b/pkg/commands/models/commit.go index b3a171934..adc7a5a51 100644 --- a/pkg/commands/models/commit.go +++ b/pkg/commands/models/commit.go @@ -9,11 +9,23 @@ import ( // Special commit hash for empty tree object const EmptyTreeCommitHash = "4b825dc642cb6eb9a060e54bf8d69288fbee4904" +type CommitStatus int + +const ( + StatusNone CommitStatus = iota + StatusUnpushed + StatusPushed + StatusMerged + StatusRebasing + StatusSelected + StatusReflog +) + // Commit : A git commit type Commit struct { Sha string Name string - Status string // one of "unpushed", "pushed", "merged", "rebasing" or "selected" + Status CommitStatus Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup" Tags []string ExtraInfo string // something like 'HEAD -> master, tag: v0.15.2' |