From 4da7d92adec7dcaf09dd384184f11450bfdfa618 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:00:30 +0800 Subject: [PATCH 01/14] try --- app/models/program.rb | 47 +++++++++++++++++++++++++++++++ app/models/scrum_sprint_member.rb | 17 +++++++++++ 2 files changed, 64 insertions(+) create mode 100644 app/models/program.rb create mode 100644 app/models/scrum_sprint_member.rb diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 0000000..75a05f2 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,47 @@ +class Program < ActiveRecord::Base + acts_as_cached(:version => 3, :expires_in => 1.day) + attr_accessible :name, :description, :assignee_id, :author_id, :outsourced, :user_ids, :project_ids, + + validates :name, presence: true, length: { maximum: 191 } + + validate :validate_category + belongs_to :assignee, class_name: 'User' + + RESOURCES = %w(projects issues pull_requests members attach_files events milestones docs) + + STANDARD = 'standard' #常规项目 + SCRUM = 'scrum' # scrum项目 + CATEGORIES = [STANDARD, SCRUM] + + class << self + def fuzzy_search(keyword) + keyword.strip! + where('`programs`.name LIKE :name', name: "%#{keyword}%") + end + end + + def is_assignee?(user_id) + user_id == assignee_id + end + + def is_scrum? + SCRUM == category + end + + # 生成项目编号 + def generate_ident + ident = enterprise.enterprise_info.lastest_ident + end + + def kafka_topic_key + "#{self.class.name}-#{self.id}" + end + + protected + + def format_content + self.outsourced ||= 0 + self.status ||= 0 + end + +end diff --git a/app/models/scrum_sprint_member.rb b/app/models/scrum_sprint_member.rb new file mode 100644 index 0000000..360660d --- /dev/null +++ b/app/models/scrum_sprint_member.rb @@ -0,0 +1,17 @@ +class ScrumSprintMember < ActiveRecord::Base + MEMBER = 1 + ASSIGNEE = 2 + ROLE_LEVELS = [MEMBER, ASSIGNEE] + + validates_uniqueness_of :user_id, scope: :scrum_sprint_id + validate :validate_role_level + + private + + def validate_role_level + return unless role_level_changed? + return if ROLE_LEVELS.include?(role_level) + + errors.add(:role_level, :error) + end +end \ No newline at end of file -- Gitee From 2d7c8e508d44e21c4b7781db61b6b26cc259b54a Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:10:07 +0800 Subject: [PATCH 02/14] change update --- .workflow/check_run-pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 8e15c24..ca31f83 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -21,12 +21,13 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance + - gem install rugged -v1.1.0 - gem install pronto - gem install pronto-rubocop - Run Script: - git fetch https://gitee.com/${AGILE_MODULE_NAME}.git pull/${AGILE_PULL_ID}/head:pr_${AGILE_PULL_ID} - - git check pr_${AGILE_PULL_ID} + - git checkout pr_${AGILE_PULL_ID} - ruby "./script/rubocop_check.rb" ${AGILE_MODULE_NAME} ${AGILE_SOURCE_REVISION} ${AGILE_REVISION} ${AGILE_PULL_ID} ${ACCESS_TOKEN} triggers: pr: -- Gitee From 0ef99e3a8da9ad1bf0700eaec00ab1be3aa3feb1 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:16:18 +0800 Subject: [PATCH 03/14] install pkg-config --- .workflow/check_run-pipeline.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index ca31f83..7fb4b0c 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -14,6 +14,9 @@ stages: - Int: - echo `ruby -v` - echo `pwd` + - APT GET: + - sudo apt-get install cmake + - sudo apt-get install pkg-config - Install RubyENV: - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ - gem install rest-client @@ -21,7 +24,6 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance - - gem install rugged -v1.1.0 - gem install pronto - gem install pronto-rubocop -- Gitee From 4866396502402faafb3102397f2b5a764714b298 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:18:06 +0800 Subject: [PATCH 04/14] install pkg-config --- .workflow/check_run-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 7fb4b0c..ea47f29 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -15,8 +15,8 @@ stages: - echo `ruby -v` - echo `pwd` - APT GET: - - sudo apt-get install cmake - - sudo apt-get install pkg-config + - apt-get install cmake + - apt-get install pkg-config - Install RubyENV: - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ - gem install rest-client -- Gitee From fe61fcfbc695d3b7f4172c48c67580c18358b882 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:31:30 +0800 Subject: [PATCH 05/14] apt-get update --- .workflow/check_run-pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index ea47f29..e7047dc 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -15,6 +15,7 @@ stages: - echo `ruby -v` - echo `pwd` - APT GET: + - apt-get update - apt-get install cmake - apt-get install pkg-config - Install RubyENV: -- Gitee From 8228f6785b4dda5b263aefbdc25486fa27027b14 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:44:59 +0800 Subject: [PATCH 06/14] disable suggestions --- .pronto.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pronto.yml b/.pronto.yml index 5489915..08b1326 100644 --- a/.pronto.yml +++ b/.pronto.yml @@ -5,4 +5,4 @@ rubocop: fatal: error # Enable suggestions - suggestions: true \ No newline at end of file + suggestions: false \ No newline at end of file -- Gitee From f87d1b03213b920a66e8f81d54538d20213fb563 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:53:42 +0800 Subject: [PATCH 07/14] suggest --- .pronto.yml | 2 +- .workflow/check_run-pipeline.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pronto.yml b/.pronto.yml index 08b1326..5489915 100644 --- a/.pronto.yml +++ b/.pronto.yml @@ -5,4 +5,4 @@ rubocop: fatal: error # Enable suggestions - suggestions: false \ No newline at end of file + suggestions: true \ No newline at end of file diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index e7047dc..5302b06 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -25,8 +25,8 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance - - gem install pronto - - gem install pronto-rubocop + - gem install pronto -v0.11.0 + - gem install pronto-rubocop -v0.11.0 - Run Script: - git fetch https://gitee.com/${AGILE_MODULE_NAME}.git pull/${AGILE_PULL_ID}/head:pr_${AGILE_PULL_ID} -- Gitee From d5a4cd9ba225b21827b12e16719fc5578e4bd677 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:59:39 +0800 Subject: [PATCH 08/14] update --- script/rubocop_check.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/rubocop_check.rb b/script/rubocop_check.rb index 1bb2e7f..db4fb2b 100644 --- a/script/rubocop_check.rb +++ b/script/rubocop_check.rb @@ -116,8 +116,8 @@ class RubocopAnalysis body: body, access_token: @access_token, path: file.path, - # position: file.line.commit_line.position, - position: file.line.commit_line.position + 1, + position: file.line.commit_line.position, + # position: file.line.commit_line.position + 1, commit_id: file.commit_sha } if get_exists_suggestions.find{|s| s[:path] == file.path && file.msg.include?(s[:body][20..-1]) && s[:commit_id] == file.commit_sha && s[:new_line] == file.line.new_lineno}.nil? -- Gitee From a4e4c037bc05cb90f54396acf0005c5acede3a4a Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 15:18:50 +0800 Subject: [PATCH 09/14] update match --- script/rubocop_check.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/script/rubocop_check.rb b/script/rubocop_check.rb index db4fb2b..e447d39 100644 --- a/script/rubocop_check.rb +++ b/script/rubocop_check.rb @@ -70,9 +70,13 @@ class RubocopAnalysis start_line = file.line.new_lineno end_line = file.line.new_lineno - message, *suggestion = file.msg.split("\n") + if file.msg.include?("suggestion") + message, suggestion = file.msg.match(/(.*)(\n\n```suggestion\n.*\n```)*/)&.captures + else + message = file.msg + end annotation_level = annotation_level_list[file.level] - unless suggestion.empty? + unless suggestion.nil? body = "Rubocop suggestion#{suggestion.join("\n")}" can_insert, suggestion = can_insert_suggestion?(file, body) suggestions.push(suggestion) if can_insert -- Gitee From 15e0705151e9a8f78965543a89fe17e19de14bcf Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 15:54:51 +0800 Subject: [PATCH 10/14] comment --- .workflow/check_run-pipeline.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 5302b06..6d1b2a6 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -37,3 +37,6 @@ triggers: branches: include: - master + comments: + include: + - GITEEGO \ No newline at end of file -- Gitee From 26b259089f144701a217fb02d15691d6868fbc4c Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 15:56:05 +0800 Subject: [PATCH 11/14] update --- app/models/user.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index cd03da4..ff6f7fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,13 +1,3 @@ class User < ApplicationRecord end -# == Schema Information -# -# Table name: users -# -# id :bigint(8) not null, primary key -# email :string -# name :string -# created_at :datetime not null -# updated_at :datetime not null -# -- Gitee From 3de49e78c962997700e6959a75a3da66de3c746b Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 17:14:44 +0800 Subject: [PATCH 12/14] rm comment --- .workflow/check_run-pipeline.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 6d1b2a6..5302b06 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -37,6 +37,3 @@ triggers: branches: include: - master - comments: - include: - - GITEEGO \ No newline at end of file -- Gitee From 15e6b9fc76eb9ef16906e08f09a095b07194621a Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 19:50:41 +0800 Subject: [PATCH 13/14] update --- script/rubocop_check.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/rubocop_check.rb b/script/rubocop_check.rb index e447d39..706c807 100644 --- a/script/rubocop_check.rb +++ b/script/rubocop_check.rb @@ -77,7 +77,7 @@ class RubocopAnalysis end annotation_level = annotation_level_list[file.level] unless suggestion.nil? - body = "Rubocop suggestion#{suggestion.join("\n")}" + body = "Rubocop suggestion#{suggestion}" can_insert, suggestion = can_insert_suggestion?(file, body) suggestions.push(suggestion) if can_insert end -- Gitee From c0c31cebfcfd1632cb3fe4318b577aa4fd79092a Mon Sep 17 00:00:00 2001 From: liwen <408815583@qq.com> Date: Wed, 30 Mar 2022 04:14:50 +0000 Subject: [PATCH 14/14] =?UTF-8?q?Apply=20all=20suggestions=20from=20code?= =?UTF-8?q?=20review=20=E6=B5=8B=E8=AF=95=E6=98=AF=E5=90=A6=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/program.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/program.rb b/app/models/program.rb index 75a05f2..7ea7e1a 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -5,9 +5,7 @@ class Program < ActiveRecord::Base validates :name, presence: true, length: { maximum: 191 } validate :validate_category - belongs_to :assignee, class_name: 'User' - - RESOURCES = %w(projects issues pull_requests members attach_files events milestones docs) + belongs_to :assignee, class_name: 'User' #liwen test STANDARD = 'standard' #常规项目 SCRUM = 'scrum' # scrum项目 -- Gitee