Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
haru committed Sep 30, 2023
2 parents 5b91078 + 236801d commit b503395
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 67 deletions.
11 changes: 7 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSI
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

RUN apt-get update
RUN apt-get install -y imagemagick
RUN apt-get install -y imagemagick git-flow

WORKDIR /usr/local
ARG REDMINE_VERSION=master
Expand All @@ -33,8 +33,8 @@ WORKDIR /usr/local/redmine
COPY .devcontainer/database.yml /usr/local/redmine/config/database.yml

RUN rm -rf .git
RUN echo "gem 'ruby-debug-ide'" >> Gemfile
RUN echo "gem 'debase'" >> Gemfile
# RUN echo "gem 'ruby-debug-ide'" >> Gemfile
RUN echo "gem 'debug'" >> Gemfile
RUN echo "gem 'rufo'" >> Gemfile
ENV DB=sqlite3
RUN bundle install
Expand All @@ -43,5 +43,8 @@ RUN bundle exec rake db:migrate RAILS_ENV=test
RUN bundle exec rake test:scm:setup:all
COPY .devcontainer/launch.json /usr/local/redmine/.vscode/launch.json
RUN chown -R vscode .
RUN sed -i "s/^end/ config.hosts.clear\nend/" config/environments/development.rb

COPY .devcontainer/post-create.sh /post-create.sh
COPY .devcontainer/post-create.sh /post-create.sh

WORKDIR /workspaces
20 changes: 16 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"dockerComposeFile": "docker-compose.yml",
"service": "app",

"workspaceFolder": "/usr/local/redmine",
"mounts": [
"source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind"
],
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// "workspaceFolder": "/workspaces/dev.code-workspace",

// Set *default* container specific settings.json values on container create.
"settings": {
Expand Down Expand Up @@ -45,7 +49,11 @@
"hridoy.rails-snippets",
"misogi.ruby-rubocop",
"jnbt.vscode-rufo",
"donjayamanne.git-extension-pack"
"donjayamanne.git-extension-pack",
"ms-azuretools.vscode-docker",
"KoichiSasada.vscode-rdbg",
"Serhioromano.vscode-gitflow",
"github.vscode-github-actions"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand All @@ -58,7 +66,11 @@
"remoteUser": "vscode",
"features": {
// "git": "latest"
}
},


"containerEnv": {
"PLUGIN_NAME": "${localWorkspaceFolderBasename}"
},

"forwardPorts": [3000]
}
5 changes: 1 addition & 4 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ services:
# Update 'VARIANT' to pick a version of Ruby: 3, 3.0, 2, 2.7, 2.6
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: "3.0"
VARIANT: "3.1"
# Optional Node.js version to install
NODE_VERSION: "lts/*"
REDMINE_VERSION: "5.0-stable"

volumes:
- ..:/usr/local/redmine/plugins/redmine_code_review:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

Expand Down
42 changes: 27 additions & 15 deletions .devcontainer/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,54 @@

{
"name": "Rails server",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
]
},
{
"name": "Rails server(postgres)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
],
"env":{
"DB": "postgres"
}
},
{
"name": "Rails server(mysql)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
],
"env":{
"DB": "mysql"
}
},
{
"name": "Plugin Test",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
Expand All @@ -54,10 +62,12 @@
},
{
"name": "Plugin Test(postgres)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
Expand All @@ -68,10 +78,12 @@
},
{
"name": "Plugin Test(mysql)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
Expand Down
12 changes: 9 additions & 3 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/sh
cd /usr/local/redmine

cp plugins/redmine_code_review/Gemfile_for_test plugins/redmine_code_review/Gemfile
ln -s /workspaces/${PLUGIN_NAME} plugins/${PLUGIN_NAME}
if [ -f plugins/${PLUGIN_NAME}/Gemfile_for_test ]
then
cp plugins/${PLUGIN_NAME}/Gemfile_for_test plugins/${PLUGIN_NAME}/Gemfile
fi
cp plugins/${PLUGIN_NAME}/test/fixtures/*.yml test/fixtures

bundle install
bundle exec rake redmine:plugins:migrate
bundle exec rake redmine:plugins:migrate RAILS_ENV=test

initdb() {
bundle exec rake db:create
Expand All @@ -15,8 +23,6 @@ initdb() {
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
}

export DB=sqlite3

initdb

export DB=postgres
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@ jobs:
strategy:
matrix:
db: [sqlite3, mysql, postgres]
ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1]
redmine_version: [4.1-stable, 4.2-stable, 5.0-stable, master]
ruby_version: ["2.7", "3.0", "3.1", "3.2"]
redmine_version: [5.0-stable, master]
exclude:
- ruby_version: 2.4
redmine_version: master
- ruby_version: 2.4
- ruby_version: "3.2"
redmine_version: 5.0-stable
- ruby_version: 2.7
redmine_version: 4.1-stable
- ruby_version: 3.0
redmine_version: 4.1-stable
- ruby_version: 3.0
redmine_version: 4.2-stable
- ruby_version: 3.1
redmine_version: 4.1-stable
- ruby_version: 3.1
redmine_version: 4.2-stable
services:
mysql:
image: mysql:5.7
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage
Gemfile
Gemfile.lock
11 changes: 11 additions & 0 deletions .redmine.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../../usr/local/redmine"
}
],
"settings": {}
}
10 changes: 4 additions & 6 deletions assets/javascripts/code_review.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
# Code Review plugin for Redmine
# Copyright (C) 2009-2017 Haruyuki Iida
# Copyright (C) 2009-2023 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -138,10 +138,8 @@ function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, att
continue;
}

var th_html = th.innerHTML;

var line = th_html.match(/[0-9]+/);
if (line == null) {
var line = $(th).data('txt');
if (line == null || line == "") {
continue;
}

Expand All @@ -151,7 +149,7 @@ function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, att
span_html += image_tag;
}
span_html += '</span>';
th.innerHTML = th_html + span_html;
th.innerHTML = span_html;

var img = th.getElementsByTagName('img')[0];
if (img != null) {
Expand Down
6 changes: 3 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code Review plugin for Redmine
# Copyright (C) 2009-2022 Haruyuki Iida
# Copyright (C) 2009-2023 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -36,8 +36,8 @@
author_url 'http://twitter.com/haru_iida'
url "http://www.redmine.org/plugins/redmine_code_review" if respond_to?(:url)
description 'This is a Code Review plugin for Redmine'
version '1.1.0'
requires_redmine :version_or_higher => '4.0.0'
version '1.1.1'
requires_redmine :version_or_higher => '5.0.0'

project_module :code_review do
permission :view_code_review, {:code_review => [:update_diff_view, :update_attachment_view, :update_revisions_view, :index, :show]}, {:read => true}
Expand Down
6 changes: 5 additions & 1 deletion lib/code_review_auto_assign_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ def yml
end

def load_yml(yml_string)
@yml = YAML.load(yml_string)
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
@yml = YAML.unsafe_load(yml_string)
else
@yml = YAML.load(yml_string)
end
end

def select_assign_to_with_list(project, list, commiter_id = nil)
Expand Down
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ def uploaded_test_file(name, mime)
end

factory :issue do
project_id {1}
tracker_id {1}
subject {'hoge'}
author {
User.find(1)
}
due_date {nil}
end

factory :code_review do
Expand Down
23 changes: 11 additions & 12 deletions test/unit/code_review_changeset_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ def test_completed_assignment_pourcent
FactoryBot.create(:change, changeset: changeset)
FactoryBot.create(:change, changeset: changeset)

issues = []
4.times{
issue = FactoryBot.create(:issue, status_id: 1, done_ratio: 0)
issues << Issue.find(issue.id)
}

changeset = Changeset.find(changeset.id)
change = changeset.filechanges[0]
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 1)
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 2)
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: issues[0].id)
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: issues[1].id)
change = changeset.filechanges[1]
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 3)
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: 4)
issues = []
1.upto(4) { |i|
issues[i - 1] = Issue.find(i)
issues[i - 1].status_id = 1
issues[i - 1].due_date = nil
issues[i - 1].done_ratio = 0
issues[i - 1].save!
}
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: issues[2].id)
change.code_review_assignments << FactoryBot.create(:code_review_assignment, issue_id: issues[3].id)

changeset.save!
changeset = Changeset.find(changeset.id)
assert_equal(0, changeset.completed_assignment_pourcent)
Expand Down

0 comments on commit b503395

Please sign in to comment.