lhj-tools 0.1.20 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/env.rb +9 -0
- data/lib/lhj/helper/git_helper.rb +14 -9
- data/lib/lhj/helper/log_helper.rb +26 -9
- data/lib/lhj/helper/pgyer_config.rb +27 -6
- data/lib/lhj/helper/pgyer_helper.rb +5 -5
- data/lib/lhj/helper/team_member_config.rb +20 -0
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8a3955d41955a54ce3ca861519c4333245dacd4c4b14477f73fc7061707c1f3
|
4
|
+
data.tar.gz: 630fc37529847a893022bd49226e2bd1bd44794f71618458d7e7620d3ad3f265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e3c30af417e17bd237c0bc114ed48d8e9fd46e39263085ef1743398e702c510ee9bd5212eaa2e06446a659a33d47089fbdc865dfcf284307538b9b6edb5abc4
|
7
|
+
data.tar.gz: e0d7853fb9f18c5785fa570c3e23c212f29e5aa935fcf437224f0f9db24c03221e3ff88efa91c8a63eb6eac8057cba5bc4ef4a0d3c798057754482c50a2e6642
|
data/lib/lhj/env.rb
ADDED
@@ -60,11 +60,11 @@ module Lhj
|
|
60
60
|
return nil if last_git_commit_formatted_with('%an').nil?
|
61
61
|
|
62
62
|
{
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
author: last_git_commit_formatted_with('%an'),
|
64
|
+
author_email: last_git_commit_formatted_with('%ae'),
|
65
|
+
message: last_git_commit_formatted_with('%B'),
|
66
|
+
commit_hash: last_git_commit_formatted_with('%H'),
|
67
|
+
abbreviated_commit_hash: last_git_commit_formatted_with('%h')
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
@@ -118,10 +118,15 @@ module Lhj
|
|
118
118
|
# Returns the current git branch, or "HEAD" if it's not checked out to any branch
|
119
119
|
# Can be replaced using the environment variable `GIT_BRANCH`
|
120
120
|
def self.git_branch
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| Lhj::Env.truthy?(env_var) }
|
122
|
+
ENV.fetch(env_name.to_s) do
|
123
|
+
# Rescues if not a git repo or no commits in a git repo
|
124
|
+
begin
|
125
|
+
Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
|
126
|
+
rescue => err
|
127
|
+
UI.verbose("Error getting git branch: #{err.message}")
|
128
|
+
nil
|
129
|
+
end
|
125
130
|
end
|
126
131
|
end
|
127
132
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'lhj/helper/team_member_config'
|
2
|
+
|
1
3
|
module Lhj
|
2
4
|
# log helper
|
3
5
|
class LogHelper
|
@@ -16,7 +18,8 @@ module Lhj
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def fetch_branch
|
19
|
-
Lhj::Actions.git_branch || ''
|
21
|
+
name = Lhj::Actions.git_branch || ''
|
22
|
+
name.split('/').last
|
20
23
|
end
|
21
24
|
|
22
25
|
def fetch_env(env)
|
@@ -24,7 +27,7 @@ module Lhj
|
|
24
27
|
when :release
|
25
28
|
'release'
|
26
29
|
when :gray
|
27
|
-
'
|
30
|
+
'gray'
|
28
31
|
else
|
29
32
|
'uat'
|
30
33
|
end
|
@@ -33,12 +36,25 @@ module Lhj
|
|
33
36
|
def fetch_log
|
34
37
|
from = last_commit_hash
|
35
38
|
to = 'HEAD'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
message = Lhj::Actions.git_log_between(' %an %ar - %s;', from, to, :exclude_merges, 'short', false)
|
40
|
+
handle_message(message)
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_message(m)
|
44
|
+
message = m
|
45
|
+
if !message.nil? && !message.empty?
|
46
|
+
message = message.gsub('seconds ', '秒')
|
47
|
+
message = message.gsub('minutes ', '分钟')
|
48
|
+
message = message.gsub('hours ', '小时')
|
49
|
+
message = message.gsub('days ', '天')
|
50
|
+
message = message.gsub('ago ', '前')
|
51
|
+
Lhj::TeamMemberConfig.config.each do |key, value|
|
52
|
+
message = message.gsub(key, value) if message =~ /#{key}/
|
53
|
+
end
|
54
|
+
else
|
55
|
+
message = '此次打包没代码更新'
|
56
|
+
end
|
57
|
+
message
|
42
58
|
end
|
43
59
|
|
44
60
|
def save_last_commit_hash
|
@@ -56,7 +72,8 @@ module Lhj
|
|
56
72
|
end
|
57
73
|
|
58
74
|
def last_commit_file
|
59
|
-
|
75
|
+
branch_name = @branch.gsub(%r{/}, '')
|
76
|
+
File.join(Lhj::Config.instance.home_dir, ".#{@env}_#{branch_name}_last_commit")
|
60
77
|
end
|
61
78
|
|
62
79
|
def render_template
|
@@ -16,16 +16,37 @@ module Lhj
|
|
16
16
|
@yaml ||= YAML.load_file(config_file)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.api_key
|
20
|
-
|
19
|
+
def self.api_key(env = :uat)
|
20
|
+
case env
|
21
|
+
when :release
|
22
|
+
'release.....'
|
23
|
+
when :gray
|
24
|
+
'gray.....'
|
25
|
+
else
|
26
|
+
config['api_key']
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
|
-
def self.user_key
|
24
|
-
|
30
|
+
def self.user_key(env = :uat)
|
31
|
+
case env
|
32
|
+
when :release
|
33
|
+
config['user_key']
|
34
|
+
when :gray
|
35
|
+
config['user_key']
|
36
|
+
else
|
37
|
+
config['user_key']
|
38
|
+
end
|
25
39
|
end
|
26
40
|
|
27
|
-
def self.password
|
28
|
-
|
41
|
+
def self.password(env = :uat)
|
42
|
+
case env
|
43
|
+
when :release
|
44
|
+
config['password']
|
45
|
+
when :gray
|
46
|
+
config['password']
|
47
|
+
else
|
48
|
+
config['password']
|
49
|
+
end
|
29
50
|
end
|
30
51
|
end
|
31
52
|
end
|
@@ -13,10 +13,10 @@ module Lhj
|
|
13
13
|
|
14
14
|
attr_reader :api_key, :user_key, :password, :result
|
15
15
|
|
16
|
-
def initialize
|
17
|
-
@api_key = Lhj::PgyerConfig.api_key
|
18
|
-
@user_key = Lhj::PgyerConfig.user_key
|
19
|
-
@password = Lhj::PgyerConfig.password
|
16
|
+
def initialize(env = :uat)
|
17
|
+
@api_key = Lhj::PgyerConfig.api_key(env)
|
18
|
+
@user_key = Lhj::PgyerConfig.user_key(env)
|
19
|
+
@password = Lhj::PgyerConfig.password(env)
|
20
20
|
@result = { 'data' => {} }
|
21
21
|
end
|
22
22
|
|
@@ -39,7 +39,7 @@ module Lhj
|
|
39
39
|
def upload_file(file, des)
|
40
40
|
|
41
41
|
update_description = @result[:update_description]
|
42
|
-
update_description =
|
42
|
+
update_description = '' if update_description.nil?
|
43
43
|
params = {
|
44
44
|
'_api_key' => @api_key,
|
45
45
|
'uKey' => @user_key,
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# team member config
|
7
|
+
class TeamMemberConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'team_member.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/lhj/tools/version.rb
CHANGED
data/lib/lhj/tools.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -326,6 +326,7 @@ files:
|
|
326
326
|
- lib/lhj/command/yapi/formatters/template/pgyer.erb
|
327
327
|
- lib/lhj/command/yapi/formatters/template/yapi.erb
|
328
328
|
- lib/lhj/config.rb
|
329
|
+
- lib/lhj/env.rb
|
329
330
|
- lib/lhj/helper/dingtalk_config.rb
|
330
331
|
- lib/lhj/helper/dingtalk_helper.rb
|
331
332
|
- lib/lhj/helper/git_helper.rb
|
@@ -337,6 +338,7 @@ files:
|
|
337
338
|
- lib/lhj/helper/pgyer_helper.rb
|
338
339
|
- lib/lhj/helper/tb_config.rb
|
339
340
|
- lib/lhj/helper/tb_helper.rb
|
341
|
+
- lib/lhj/helper/team_member_config.rb
|
340
342
|
- lib/lhj/helper/trans_helper.rb
|
341
343
|
- lib/lhj/tools.rb
|
342
344
|
- lib/lhj/tools/version.rb
|