hiiro 0.1.52 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/h-pane +1 -1
- data/bin/h-window +1 -1
- data/lib/hiiro/history/entry.rb +135 -0
- data/lib/hiiro/history.rb +1 -132
- data/lib/hiiro/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5b124b6980d905a9d41a47e5f81de7aa5920ba8047168a952fb826a7bf98df2
|
|
4
|
+
data.tar.gz: 2fc08d8b0de4bb03678bcf15f07bde9b4e74745260cb2b5c83f1d6601cb3dce1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 053f53b20484aa74d612d2948a7c4439ed6b901d2bd7a4d600cabd84c8fd012c7e9903898a69243c3aca7de753ec37a66192d3915337c503c16eb2152075f0a0
|
|
7
|
+
data.tar.gz: ae6342874f5bcda420849a100a7830fd910802d76b7302a8d6e41707c5184f5f7029933e54600e1f314c04d37c593c3edfe2a6ab9ac125b5a061fc41e140fbb5
|
data/bin/h-pane
CHANGED
data/bin/h-window
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
class Hiiro
|
|
2
|
+
class History
|
|
3
|
+
class Entry
|
|
4
|
+
FIELDS = %i[
|
|
5
|
+
id timestamp source cmd description pwd
|
|
6
|
+
tmux_session tmux_window tmux_pane
|
|
7
|
+
git_branch git_sha git_origin_sha git_worktree
|
|
8
|
+
task subtask app
|
|
9
|
+
].freeze
|
|
10
|
+
|
|
11
|
+
attr_reader(*FIELDS)
|
|
12
|
+
|
|
13
|
+
def initialize(data)
|
|
14
|
+
data ||= {}
|
|
15
|
+
@id = data['id']
|
|
16
|
+
@timestamp = data['timestamp']
|
|
17
|
+
@source = data['source']
|
|
18
|
+
@cmd = data['cmd']
|
|
19
|
+
@description = data['description']
|
|
20
|
+
@pwd = data['pwd']
|
|
21
|
+
@tmux_session = data['tmux_session']
|
|
22
|
+
@tmux_window = data['tmux_window']
|
|
23
|
+
@tmux_pane = data['tmux_pane']
|
|
24
|
+
@git_branch = data['git_branch']
|
|
25
|
+
@git_sha = data['git_sha']
|
|
26
|
+
@git_origin_sha = data['git_origin_sha']
|
|
27
|
+
@git_worktree = data['git_worktree']
|
|
28
|
+
@task = data['task']
|
|
29
|
+
@subtask = data['subtask']
|
|
30
|
+
@app = data['app']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_h
|
|
34
|
+
{
|
|
35
|
+
'id' => id,
|
|
36
|
+
'timestamp' => timestamp,
|
|
37
|
+
'source' => source,
|
|
38
|
+
'cmd' => cmd,
|
|
39
|
+
'description' => description,
|
|
40
|
+
'pwd' => pwd,
|
|
41
|
+
'tmux_session' => tmux_session,
|
|
42
|
+
'tmux_window' => tmux_window,
|
|
43
|
+
'tmux_pane' => tmux_pane,
|
|
44
|
+
'git_branch' => git_branch,
|
|
45
|
+
'git_sha' => git_sha,
|
|
46
|
+
'git_origin_sha' => git_origin_sha,
|
|
47
|
+
'git_worktree' => git_worktree,
|
|
48
|
+
'task' => task,
|
|
49
|
+
'subtask' => subtask,
|
|
50
|
+
'app' => app,
|
|
51
|
+
}.compact
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Data used for change detection (excludes timestamp, id, cmd)
|
|
55
|
+
def state_key
|
|
56
|
+
{
|
|
57
|
+
'pwd' => pwd,
|
|
58
|
+
'tmux_session' => tmux_session,
|
|
59
|
+
'tmux_window' => tmux_window,
|
|
60
|
+
'tmux_pane' => tmux_pane,
|
|
61
|
+
'git_branch' => git_branch,
|
|
62
|
+
'git_sha' => git_sha,
|
|
63
|
+
'git_origin_sha' => git_origin_sha,
|
|
64
|
+
'git_worktree' => git_worktree,
|
|
65
|
+
'task' => task,
|
|
66
|
+
'subtask' => subtask,
|
|
67
|
+
'app' => app,
|
|
68
|
+
}.compact
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def state_fingerprint
|
|
72
|
+
Digest::SHA256.hexdigest(state_key.to_yaml)[0..15]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def short_line(index)
|
|
76
|
+
time_str = timestamp ? Time.parse(timestamp).strftime('%Y-%m-%d %H:%M') : Time.now.strftime('%Y-%m-%d %H:%M')
|
|
77
|
+
desc = description || cmd || '(no description)'
|
|
78
|
+
desc = desc[0..50] + '...' if desc.length > 53
|
|
79
|
+
[
|
|
80
|
+
format('%3d %s %s', index, time_str, desc),
|
|
81
|
+
format(' %s @ %s', git_branch || '(no branch)', task || '(no task)'),
|
|
82
|
+
].join("\n")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def oneline(index = nil)
|
|
86
|
+
time_str = timestamp ? Time.parse(timestamp).strftime('%m/%d %H:%M') : ''
|
|
87
|
+
prefix = index ? format('%3d ', index) : ''
|
|
88
|
+
branch_str = git_branch ? "[#{git_branch}]" : ''
|
|
89
|
+
task_str = task ? "(#{task})" : ''
|
|
90
|
+
cmd_str = cmd || description || ''
|
|
91
|
+
cmd_str = cmd_str[0..40] + '...' if cmd_str.length > 43
|
|
92
|
+
|
|
93
|
+
"#{prefix}#{time_str} #{branch_str.ljust(20)} #{task_str.ljust(15)} #{cmd_str}"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def full_display
|
|
97
|
+
lines = []
|
|
98
|
+
lines << "ID: #{id}"
|
|
99
|
+
lines << "Timestamp: #{timestamp}"
|
|
100
|
+
lines << "Description: #{description}" if description
|
|
101
|
+
lines << "Command: #{cmd}" if cmd
|
|
102
|
+
lines << "PWD: #{pwd}" if pwd
|
|
103
|
+
lines << "Source: #{source}" if source
|
|
104
|
+
lines << ""
|
|
105
|
+
lines << "Tmux:"
|
|
106
|
+
lines << " Session: #{tmux_session}" if tmux_session
|
|
107
|
+
lines << " Window: #{tmux_window}" if tmux_window
|
|
108
|
+
lines << " Pane: #{tmux_pane}" if tmux_pane
|
|
109
|
+
lines << ""
|
|
110
|
+
lines << "Git:"
|
|
111
|
+
lines << " Worktree: #{git_worktree}" if git_worktree
|
|
112
|
+
lines << " Branch: #{git_branch}" if git_branch
|
|
113
|
+
lines << " SHA: #{git_sha}" if git_sha
|
|
114
|
+
lines << " Origin: #{git_origin_sha}" if git_origin_sha
|
|
115
|
+
lines << ""
|
|
116
|
+
lines << "Task:"
|
|
117
|
+
lines << " Task: #{task}" if task
|
|
118
|
+
lines << " Subtask: #{subtask}" if subtask
|
|
119
|
+
lines << " App: #{app}" if app
|
|
120
|
+
lines.join("\n")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Filter matching
|
|
124
|
+
def matches?(filters)
|
|
125
|
+
filters.all? do |key, value|
|
|
126
|
+
entry_value = send(key) rescue nil
|
|
127
|
+
next true if value.nil?
|
|
128
|
+
next entry_value == value if value.is_a?(String)
|
|
129
|
+
next value.include?(entry_value) if value.is_a?(Array)
|
|
130
|
+
true
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
data/lib/hiiro/history.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'yaml'
|
|
|
2
2
|
require 'time'
|
|
3
3
|
require 'fileutils'
|
|
4
4
|
require 'digest'
|
|
5
|
+
require_relative 'history/entry'
|
|
5
6
|
|
|
6
7
|
class Hiiro
|
|
7
8
|
class History
|
|
@@ -9,138 +10,6 @@ class Hiiro
|
|
|
9
10
|
HISTORY_FILE = File.join(HISTORY_DIR, 'entries.yml')
|
|
10
11
|
LAST_STATE_FILE = File.join(HISTORY_DIR, 'last_state.yml')
|
|
11
12
|
|
|
12
|
-
class Entry
|
|
13
|
-
FIELDS = %i[
|
|
14
|
-
id timestamp source cmd description pwd
|
|
15
|
-
tmux_session tmux_window tmux_pane
|
|
16
|
-
git_branch git_sha git_origin_sha git_worktree
|
|
17
|
-
task subtask app
|
|
18
|
-
].freeze
|
|
19
|
-
|
|
20
|
-
attr_reader(*FIELDS)
|
|
21
|
-
|
|
22
|
-
def initialize(data)
|
|
23
|
-
data ||= {}
|
|
24
|
-
@id = data['id']
|
|
25
|
-
@timestamp = data['timestamp']
|
|
26
|
-
@source = data['source']
|
|
27
|
-
@cmd = data['cmd']
|
|
28
|
-
@description = data['description']
|
|
29
|
-
@pwd = data['pwd']
|
|
30
|
-
@tmux_session = data['tmux_session']
|
|
31
|
-
@tmux_window = data['tmux_window']
|
|
32
|
-
@tmux_pane = data['tmux_pane']
|
|
33
|
-
@git_branch = data['git_branch']
|
|
34
|
-
@git_sha = data['git_sha']
|
|
35
|
-
@git_origin_sha = data['git_origin_sha']
|
|
36
|
-
@git_worktree = data['git_worktree']
|
|
37
|
-
@task = data['task']
|
|
38
|
-
@subtask = data['subtask']
|
|
39
|
-
@app = data['app']
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def to_h
|
|
43
|
-
{
|
|
44
|
-
'id' => id,
|
|
45
|
-
'timestamp' => timestamp,
|
|
46
|
-
'source' => source,
|
|
47
|
-
'cmd' => cmd,
|
|
48
|
-
'description' => description,
|
|
49
|
-
'pwd' => pwd,
|
|
50
|
-
'tmux_session' => tmux_session,
|
|
51
|
-
'tmux_window' => tmux_window,
|
|
52
|
-
'tmux_pane' => tmux_pane,
|
|
53
|
-
'git_branch' => git_branch,
|
|
54
|
-
'git_sha' => git_sha,
|
|
55
|
-
'git_origin_sha' => git_origin_sha,
|
|
56
|
-
'git_worktree' => git_worktree,
|
|
57
|
-
'task' => task,
|
|
58
|
-
'subtask' => subtask,
|
|
59
|
-
'app' => app,
|
|
60
|
-
}.compact
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Data used for change detection (excludes timestamp, id, cmd)
|
|
64
|
-
def state_key
|
|
65
|
-
{
|
|
66
|
-
'pwd' => pwd,
|
|
67
|
-
'tmux_session' => tmux_session,
|
|
68
|
-
'tmux_window' => tmux_window,
|
|
69
|
-
'tmux_pane' => tmux_pane,
|
|
70
|
-
'git_branch' => git_branch,
|
|
71
|
-
'git_sha' => git_sha,
|
|
72
|
-
'git_origin_sha' => git_origin_sha,
|
|
73
|
-
'git_worktree' => git_worktree,
|
|
74
|
-
'task' => task,
|
|
75
|
-
'subtask' => subtask,
|
|
76
|
-
'app' => app,
|
|
77
|
-
}.compact
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def state_fingerprint
|
|
81
|
-
Digest::SHA256.hexdigest(state_key.to_yaml)[0..15]
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def short_line(index)
|
|
85
|
-
time_str = timestamp ? Time.parse(timestamp).strftime('%Y-%m-%d %H:%M') : Time.now.strftime('%Y-%m-%d %H:%M')
|
|
86
|
-
desc = description || cmd || '(no description)'
|
|
87
|
-
desc = desc[0..50] + '...' if desc.length > 53
|
|
88
|
-
[
|
|
89
|
-
format('%3d %s %s', index, time_str, desc),
|
|
90
|
-
format(' %s @ %s', git_branch || '(no branch)', task || '(no task)'),
|
|
91
|
-
].join("\n")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def oneline(index = nil)
|
|
95
|
-
time_str = timestamp ? Time.parse(timestamp).strftime('%m/%d %H:%M') : ''
|
|
96
|
-
prefix = index ? format('%3d ', index) : ''
|
|
97
|
-
branch_str = git_branch ? "[#{git_branch}]" : ''
|
|
98
|
-
task_str = task ? "(#{task})" : ''
|
|
99
|
-
cmd_str = cmd || description || ''
|
|
100
|
-
cmd_str = cmd_str[0..40] + '...' if cmd_str.length > 43
|
|
101
|
-
|
|
102
|
-
"#{prefix}#{time_str} #{branch_str.ljust(20)} #{task_str.ljust(15)} #{cmd_str}"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def full_display
|
|
106
|
-
lines = []
|
|
107
|
-
lines << "ID: #{id}"
|
|
108
|
-
lines << "Timestamp: #{timestamp}"
|
|
109
|
-
lines << "Description: #{description}" if description
|
|
110
|
-
lines << "Command: #{cmd}" if cmd
|
|
111
|
-
lines << "PWD: #{pwd}" if pwd
|
|
112
|
-
lines << "Source: #{source}" if source
|
|
113
|
-
lines << ""
|
|
114
|
-
lines << "Tmux:"
|
|
115
|
-
lines << " Session: #{tmux_session}" if tmux_session
|
|
116
|
-
lines << " Window: #{tmux_window}" if tmux_window
|
|
117
|
-
lines << " Pane: #{tmux_pane}" if tmux_pane
|
|
118
|
-
lines << ""
|
|
119
|
-
lines << "Git:"
|
|
120
|
-
lines << " Worktree: #{git_worktree}" if git_worktree
|
|
121
|
-
lines << " Branch: #{git_branch}" if git_branch
|
|
122
|
-
lines << " SHA: #{git_sha}" if git_sha
|
|
123
|
-
lines << " Origin: #{git_origin_sha}" if git_origin_sha
|
|
124
|
-
lines << ""
|
|
125
|
-
lines << "Task:"
|
|
126
|
-
lines << " Task: #{task}" if task
|
|
127
|
-
lines << " Subtask: #{subtask}" if subtask
|
|
128
|
-
lines << " App: #{app}" if app
|
|
129
|
-
lines.join("\n")
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Filter matching
|
|
133
|
-
def matches?(filters)
|
|
134
|
-
filters.all? do |key, value|
|
|
135
|
-
entry_value = send(key) rescue nil
|
|
136
|
-
next true if value.nil?
|
|
137
|
-
next entry_value == value if value.is_a?(String)
|
|
138
|
-
next value.include?(entry_value) if value.is_a?(Array)
|
|
139
|
-
true
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
13
|
class << self
|
|
145
14
|
def load(hiiro)
|
|
146
15
|
history = new
|
data/lib/hiiro/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.53
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
@@ -77,6 +77,7 @@ files:
|
|
|
77
77
|
- lib/hiiro/git/worktree.rb
|
|
78
78
|
- lib/hiiro/git/worktrees.rb
|
|
79
79
|
- lib/hiiro/history.rb
|
|
80
|
+
- lib/hiiro/history/entry.rb
|
|
80
81
|
- lib/hiiro/options.rb
|
|
81
82
|
- lib/hiiro/sk.rb
|
|
82
83
|
- lib/hiiro/version.rb
|