lhj-tools 0.1.23 → 0.1.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdb58f24fe8dec97319d3dc8e8bbadffe0c05d79ec2ce4092e1e8b6eeabed65a
4
- data.tar.gz: 3fe9ae37c1087b85b5aa7d6fbdf7e4017665843a148c040c2fc3a58bbcd4c382
3
+ metadata.gz: f8a3955d41955a54ce3ca861519c4333245dacd4c4b14477f73fc7061707c1f3
4
+ data.tar.gz: 630fc37529847a893022bd49226e2bd1bd44794f71618458d7e7620d3ad3f265
5
5
  SHA512:
6
- metadata.gz: 125b3650d4d7195b5a07569df7678f976094591292c4d9e5d961e4ccef588f29c6f62e4f7ddaebcdafb558d2f287b00170a0606f72b34b0fedfa0dd2979996e5
7
- data.tar.gz: 95cf649f1f6cf458822bc7d7a9143be7bcc8b24f4da4dfdcc7a10e291d58d4e85d24bfff6e3a84f1178e68e547e04fca744d45480cf02da43a1e54c3b0237292
6
+ metadata.gz: 0e3c30af417e17bd237c0bc114ed48d8e9fd46e39263085ef1743398e702c510ee9bd5212eaa2e06446a659a33d47089fbdc865dfcf284307538b9b6edb5abc4
7
+ data.tar.gz: e0d7853fb9f18c5785fa570c3e23c212f29e5aa935fcf437224f0f9db24c03221e3ff88efa91c8a63eb6eac8057cba5bc4ef4a0d3c798057754482c50a2e6642
@@ -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)
@@ -33,12 +36,25 @@ module Lhj
33
36
  def fetch_log
34
37
  from = last_commit_hash
35
38
  to = 'HEAD'
36
- changelog = Lhj::Actions.git_log_between(' %an, %ar - %s;', from, to, :exclude_merges, 'short', false)
37
- changelog ||= ''
38
- changelog&.gsub("\n\n", "\n")
39
- changelog = changelog.gsub('seconds ', '秒').gsub('minutes ', '分钟').gsub('hours ', '小时').gsub('days ', '天').gsub('ago ', '前')
40
- changelog = '此次打包没代码更新' if changelog.empty?
41
- changelog
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,8 +72,8 @@ module Lhj
56
72
  end
57
73
 
58
74
  def last_commit_file
59
- file_name = @branch.gsub(%r{/}, '')
60
- File.join(Lhj::Config.instance.home_dir, ".#{file_name}_last_commit")
75
+ branch_name = @branch.gsub(%r{/}, '')
76
+ File.join(Lhj::Config.instance.home_dir, ".#{@env}_#{branch_name}_last_commit")
61
77
  end
62
78
 
63
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
- config['api_key']
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
- config['user_key']
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
- config['password']
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 = "" if update_description.nil?
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.23"
5
+ VERSION = "0.1.24"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
@@ -338,6 +338,7 @@ files:
338
338
  - lib/lhj/helper/pgyer_helper.rb
339
339
  - lib/lhj/helper/tb_config.rb
340
340
  - lib/lhj/helper/tb_helper.rb
341
+ - lib/lhj/helper/team_member_config.rb
341
342
  - lib/lhj/helper/trans_helper.rb
342
343
  - lib/lhj/tools.rb
343
344
  - lib/lhj/tools/version.rb