Skip to content

Commit

Permalink
refactor: move stash data parsing into log-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed May 10, 2023
1 parent 73d086d commit 7fed1a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 14 additions & 1 deletion web/src/views/log-utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ git_ref_sort = (###* @type {GitRef} ### a, ###* @type {GitRef} ### b) =>
# extraction is the main purpose of this function.
# @param log_data {string}
# @param branch_data {string}
# @param stash_data {string}
# @param separator {string}
###
parse = (log_data, branch_data, separator) =>
parse = (log_data, branch_data, stash_data, separator) =>
lines = log_data.split '\n'

``###* @type {Branch[]} ###
Expand Down Expand Up @@ -237,6 +238,18 @@ parse = (log_data, branch_data, separator) =>
.sort git_ref_sort
.slice(0, 350)

# stashes were queried (git reflog show stash) but shown as commits. Need to add refs:
for stash from (stash_data or '').split('\n')
# 7c37db63 stash@{11}
split = stash.split(' ')
commit = commits.find((c) => c.hash == split[0])
name = split.slice(1).join(' ')
commit?.refs.push
name: name
id: name
type: "stash"
color: '#fff'

{ commits, branches, vis_max_length }

export { parse }
13 changes: 1 addition & 12 deletions web/src/views/store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,7 @@ export git_run_log = (###* @type string ### log_args) =>
git 'status'
]
return if not log_data
parsed = parse log_data, branch_data, sep
# stashes are queried (git reflog show stash) but shown as commits. Need to add refs:
for stash from (stash_data or '').split('\n')
# 7c37db63 stash@{11}
split = stash.split(' ')
commit = parsed.commits.find((c) => c.hash == split[0])
name = split.slice(1).join(' ')
commit?.refs.push
name: name
id: name
type: "stash"
color: '#fff'
parsed = parse log_data, branch_data, stash_data, sep
commits.value = parsed.commits
branches.value = parsed.branches
# todo rename to vis_max_amount
Expand Down

0 comments on commit 7fed1a5

Please sign in to comment.