fewald-worklog 0.3.9 → 0.3.10
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/.version +1 -1
- data/lib/github/pull_request_event.rb +1 -1
- data/lib/github/pull_request_review_event.rb +18 -2
- data/lib/github/push_event.rb +1 -1
- data/lib/people_storage.rb +10 -3
- data/lib/worklog.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c918d6adace19f7c6fcf87f5a52a82c3fd3c60ddfc85e4042299e67dc204a17a
|
|
4
|
+
data.tar.gz: d901d4d78036bb7754f58406f47a9d003690dec8a087cffcaf77bc55e0d4de26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7400ed28bd389bbe70c51a61abfd63ae3fe3cbc7575273b8383e85aeef6b11137b8f645b57e65fc8f5bd6bb3fe5814387b9c3b2b9e11f755dd1bae933854d2f
|
|
7
|
+
data.tar.gz: a016e500815e38dfbb4308fe07ce599fc46f71eaf96c7fc3af668198f00b3985f09f7d02144faadca83c326cfd8b91ce201aa56b2077bae7545c012000cb7670
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.10
|
|
@@ -40,10 +40,12 @@ module Worklog
|
|
|
40
40
|
|
|
41
41
|
# Convert the PullRequestReviewEvent to a LogEntry
|
|
42
42
|
# @return [LogEntry]
|
|
43
|
-
def to_log_entry
|
|
43
|
+
def to_log_entry(people_storage = nil)
|
|
44
|
+
handle = resolve_username(people_storage) || creator
|
|
45
|
+
|
|
44
46
|
message = String.new 'Reviewed '
|
|
45
47
|
message << 'and approved ' if approved?
|
|
46
|
-
message << "PR ##{number} #{
|
|
48
|
+
message << "PR ##{number} #{handle}: #{title}"
|
|
47
49
|
LogEntry.new(
|
|
48
50
|
key: Hasher.sha256("#{repository}-#{number}-#{state}"),
|
|
49
51
|
source: 'github',
|
|
@@ -58,6 +60,20 @@ module Worklog
|
|
|
58
60
|
def to_s
|
|
59
61
|
"#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
|
|
60
62
|
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# Resolve the GitHub username to a person handle using the provided PeopleStorage
|
|
67
|
+
# @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution
|
|
68
|
+
# @return [String, nil] The person handle if found, otherwise nil
|
|
69
|
+
# @example
|
|
70
|
+
# resolve_username(people_storage) #=> "~johndoe"
|
|
71
|
+
def resolve_username(people_storage)
|
|
72
|
+
return if people_storage.nil?
|
|
73
|
+
|
|
74
|
+
person = people_storage.find_by_github_username(creator)
|
|
75
|
+
person ? "~#{person.handle}" : nil
|
|
76
|
+
end
|
|
61
77
|
end
|
|
62
78
|
end
|
|
63
79
|
end
|
data/lib/github/push_event.rb
CHANGED
data/lib/people_storage.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'person'
|
|
4
|
+
require 'worklogger'
|
|
3
5
|
require 'yaml'
|
|
4
|
-
|
|
5
|
-
require_relative 'person'
|
|
6
|
+
|
|
6
7
|
module Worklog
|
|
7
|
-
#
|
|
8
|
+
# Finding, reading, and writing of people
|
|
9
|
+
# @see Person
|
|
10
|
+
# @see Storage
|
|
8
11
|
class PeopleStorage
|
|
9
12
|
PEOPLE_FILE = 'people.yaml'
|
|
10
13
|
|
|
@@ -14,7 +17,11 @@ module Worklog
|
|
|
14
17
|
---
|
|
15
18
|
# Each person is defined by the following attributes:
|
|
16
19
|
# - handle: <unique_handle>
|
|
20
|
+
# Unique handle used to reference this person (e.g., ~jdoe)
|
|
17
21
|
# github_username: <github_username>
|
|
22
|
+
# GitHub username of the person, used to link GitHub events to this person.
|
|
23
|
+
# This can be omitted if the person does not have a GitHub account and can
|
|
24
|
+
# be different from the handle.
|
|
18
25
|
# name: <full_name>
|
|
19
26
|
# team: <team_name>
|
|
20
27
|
# email: <email_address>
|
data/lib/worklog.rb
CHANGED
|
@@ -154,7 +154,7 @@ module Worklog
|
|
|
154
154
|
daily_log = @storage.load_log!(@storage.filepath(date))
|
|
155
155
|
entries_before = daily_log.entries.size
|
|
156
156
|
events.each do |event|
|
|
157
|
-
log_entry = event.to_log_entry
|
|
157
|
+
log_entry = event.to_log_entry(@people_storage)
|
|
158
158
|
WorkLogger.debug('Entry already exists, skipping') if daily_log.key?(log_entry.key)
|
|
159
159
|
daily_log << log_entry unless daily_log.key?(log_entry.key)
|
|
160
160
|
WorkLogger.debug "Added entry: #{log_entry.message_string}"
|