diff --git a/.github/workflows/brakeman.yml b/.github/workflows/brakeman.yml new file mode 100644 index 00000000000..ca17e384af0 --- /dev/null +++ b/.github/workflows/brakeman.yml @@ -0,0 +1,35 @@ +name: Run Brakeman + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + pandoc + + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + + - name: Setup gems + run: | + echo "source 'https://rubygems.org'" > Gemfile + echo "group :test do" >> Gemfile + echo " gem 'brakeman', require: false" >> Gemfile + echo " gem 'pandoc-ruby', require: false" >> Gemfile + echo "end">> Gemfile + gem install bundler + bundle install --jobs 4 --retry 3 + + - name: Run Brakeman + run: | + bundle exec brakeman -5 diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 00000000000..a616939d420 --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,44 @@ +name: Run Linters + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + pandoc + + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + + - name: Setup gems + run: | + echo "source 'https://rubygems.org'" > Gemfile + echo "group :test do" >> Gemfile + echo " gem 'pandoc-ruby', require: false" >> Gemfile + echo " gem 'rubocop', require: false" >> Gemfile + echo " gem 'rubocop-performance', require: false" >> Gemfile + echo " gem 'rubocop-rails', require: false" >> Gemfile + echo " gem 'rubocop-rspec', require: false" >> Gemfile + echo " gem 'slim_lint', require: false" >> Gemfile + echo "end" >> Gemfile + gem install bundler + bundle install --jobs 4 --retry 3 + + - name: Run RuboCop + run: | + bundle exec rubocop -S + + - name: Run Slim-Lint + run: | + bundle exec slim-lint app/views + if: always() diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..84dfc7454f3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,162 @@ +name: Test +on: + push: + pull_request: + +jobs: + test: + name: ${{ matrix.redmine }} ${{ matrix.db }} ruby-${{ matrix.ruby }} + runs-on: ubuntu-latest + + strategy: + matrix: + ruby: ['2.6', '2.4'] + redmine: ['4.1-stable', 'master'] + db: ['postgres', 'mysql'] + fail-fast: false + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + mysql: + image: mysql:5.7 + env: + MYSQL_USER: root + MYSQL_PASSWORD: '' + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + steps: + - name: Verify MySQL connection from host + run: | + mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES" + if: matrix.db == 'mysql' + + - name: Checkout Redmine + uses: actions/checkout@v2 + with: + repository: redmine/redmine + ref: ${{ matrix.redmine }} + path: redmine + + - name: Checkout redmine_git_hosting + uses: actions/checkout@v2 + with: + path: redmine/plugins/redmine_git_hosting + + - name: Checkout additionals + uses: actions/checkout@v2 + with: + repository: AlphaNodes/additionals + path: redmine/plugins/additionals + + - name: Checkout redmine_sidekiq + uses: actions/checkout@v2 + with: + repository: ogom/redmine_sidekiq + path: redmine/plugins/redmine_sidekiq + + - name: Checkout gitolite + uses: actions/checkout@v2 + with: + repository: sitaramc/gitolite + path: gitolite + + - name: Update package archives + run: sudo apt-get update --yes --quiet + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + build-essential + cmake + libgpg-error-dev + libicu-dev + libpq-dev + libmysqlclient-dev + libssh2-1 + libssh2-1-dev + subversion + + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - name: Setup Cache + uses: actions/cache@v1 + with: + path: vendor + key: v1-ruby-${{ matrix.ruby }}-redmine-${{ matrix.redmine }} + + - name: Setup Bundler + run: | + gem install bundler -v '~> 1.0' + bundle config path "$(pwd)/vendor/bundle" + + - name: Prepare Redmine source + working-directory: redmine + run: | + sed -i '/rubocop/d' Gemfile + rm -f .rubocop* + cp plugins/redmine_git_hosting/contrib/github/database-${{ matrix.db }}.yml config/database.yml + + - name: Install admin ssh key + working-directory: redmine + run: | + ssh-keygen -N '' -f plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa + + - name: Install Gitolite + working-directory: redmine + run: | + sudo useradd --create-home git + sudo -n -u git -i mkdir bin + sudo -n -u git -i $GITHUB_WORKSPACE/gitolite/install -to /home/git/bin + sudo cp plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa.pub /home/git/ + sudo chown git.git /home/git/redmine_gitolite_admin_id_rsa.pub + sudo -n -u git -i bin/gitolite setup -pk redmine_gitolite_admin_id_rsa.pub + + - name: Install Ruby dependencies + working-directory: redmine + run: | + bundle install --jobs=4 --retry=3 --without development + + - name: Run Redmine rake tasks + env: + RAILS_ENV: test + working-directory: redmine + run: | + bundle exec rake generate_secret_token + bundle exec rake db:create db:migrate redmine:plugins:migrate + bundle exec rake db:test:prepare + + - name: Install rspec file + working-directory: redmine + run: | + mkdir spec + cp plugins/redmine_git_hosting/spec/root_spec_helper.rb spec/spec_helper.rb + + - name: Run tests + env: + RAILS_ENV: test + REDMINE_VERSION: ${{ matrix.redmine }} + working-directory: redmine + run: bundle exec rake redmine_git_hosting:ci:all diff --git a/.gitignore b/.gitignore index 14db4b0828f..e9bbcc24d7e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ settings.yml /coverage /junit custom_hooks.rb +/ssh_keys/redmine_gitolite_admin_id_rsa* +.DS_Store +coverage/ diff --git a/.rubocop.yml b/.rubocop.yml index 828e2e884d9..66e7a3f8332 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,16 @@ +inherit_from: .rubocop_todo.yml + require: - - rubocop-rspec - rubocop-performance + - rubocop-rails Rails: Enabled: true AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.4 TargetRailsVersion: 5.2 + NewCops: enable Include: - '**/*.ruby' - '**/*.rake' @@ -17,44 +20,65 @@ AllCops: - '**/Gemfile' Metrics/AbcSize: - Max: 65 + Enabled: false Metrics/BlockLength: - Max: 60 + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: - Max: 20 + Enabled: false -Metrics/LineLength: +Layout/LineLength: Max: 140 Metrics/MethodLength: - Max: 60 + Enabled: false Metrics/ModuleLength: Enabled: false Metrics/PerceivedComplexity: - Max: 25 + Max: 45 -Rails/SkipsModelValidations: +Rails/ApplicationJob: + Enabled: false + +Rails/ApplicationRecord: Enabled: false Rails/CreateTableWithTimestamps: Enabled: false -# app/model/application_record.rb is missing in redmine, we can't use ApplicationRecord -Rails/ApplicationRecord: +Rails/HelperInstanceVariable: Enabled: false -Style/FrozenStringLiteralComment: +Rails/SkipsModelValidations: Enabled: false +Performance/ChainArrayAllocation: + Enabled: true + Style/AutoResourceCleanup: Enabled: true +Style/FrozenStringLiteralComment: + Enabled: false + Style/Documentation: Enabled: false + +# required for travis/ci (symbolic links problem) +Style/ExpandPathArguments: + Enabled: false + +Style/HashTransformKeys: + Enabled: false + +Style/HashTransformValues: + Enabled: false + +Naming/VariableNumber: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000000..7aeb55961c7 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,968 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2020-12-22 17:24:13 UTC using RuboCop version 1.6.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 35 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 614 + +# Offense count: 4 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'app/services/redmine_hooks/update_mirrors.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/patches/grack_auth_patch.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 14 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/helpers/gitolite_public_keys_helper_spec.rb' + - 'spec/lib/redmine_git_hosting/config_spec.rb' + - 'spec/models/gitolite_public_key_spec.rb' + - 'spec/models/repository_deployment_credential_spec.rb' + - 'spec/models/repository_mirror_spec.rb' + - 'spec/models/repository_xitolite_spec.rb' + - 'spec/support/flat_organization.rb' + - 'spec/support/hierarchical_organisation.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'spec/factories/member.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/Loop: + Exclude: + - 'app/use_cases/gitolite_public_keys/generate_identifier.rb' + +# Offense count: 5 +Lint/MissingSuper: + Exclude: + - 'lib/redmine_git_hosting/error.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/base.rb' + - 'lib/redmine_git_hosting/plugins/extenders/base_extender.rb' + - 'lib/redmine_git_hosting/plugins/gitolite_plugin.rb' + - 'lib/redmine_git_hosting/plugins/sweepers/base_sweeper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'spec/root_spec_helper.rb' + +# Offense count: 1 +Lint/NonLocalExitFromIterator: + Exclude: + - 'app/workers/githosting_shell_worker.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantStringCoercion: + Exclude: + - 'lib/redmine_git_hosting/recycle_bin/deletable_item.rb' + +# Offense count: 1 +Lint/RescueException: + Exclude: + - 'lib/redmine_git_hosting/gitolite_hooks.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/SendWithMixinArgument: + Exclude: + - 'lib/redmine_git_hosting/patches/projects_controller_patch.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/ToJSON: + Exclude: + - 'lib/redmine_git_hosting/git_access_status.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'app/reports/repository_contributors_stats.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'app/services/redmine_hooks/base.rb' + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'lib/redmine_git_hosting/cache/memcached.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/console_logger.rb' + - 'lib/redmine_git_hosting/mirror_keys_installer.rb' + - 'spec/support/crud_controller_spec/helpers.rb' + +# Offense count: 1 +Lint/UriEscapeUnescape: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_http_helper.rb' + +# Offense count: 37 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters. +Metrics/ParameterLists: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 7 +Naming/AccessorMethodName: + Exclude: + - 'app/models/concerns/gitolitable/paths.rb' + - 'contrib/hooks/post-receive/lib/git_hosting_custom_hook.rb' + - 'lib/redmine_git_hosting/gitolite_params/mailer_params.rb' + - 'lib/redmine_git_hosting/recycle_bin/manager.rb' + - 'lib/redmine_git_hosting/redmine_plugin_loader.rb' + - 'spec/support/global_helpers.rb' + +# Offense count: 3 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'app/reports/repository_contributors_stats.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/redmine_plugin_loader.rb' + +# Offense count: 3 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + - 'app/models/gitolite_public_key.rb' + - 'lib/redmine_git_hosting/patches/grack_auth_patch.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/redmine_git_hosting/gitolite_hooks.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Performance/BlockGivenWithExplicitBlock: + Exclude: + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/console_logger.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 31 +Performance/ChainArrayAllocation: + Exclude: + - 'app/forms/plugin_settings_form.rb' + - 'app/models/concerns/gitolitable/notifications.rb' + - 'app/models/concerns/gitolitable/users.rb' + - 'app/models/repository_protected_branche.rb' + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'db/migrate/20150823030100_migrate_protected_branches_users.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/projects/common.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/projects/move_repositories.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/projects/move_repositories_tree.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/projects/update_projects.rb' + - 'lib/redmine_git_hosting/patches/changeset_patch.rb' + - 'lib/redmine_git_hosting/patches/project_patch.rb' + - 'lib/redmine_git_hosting/patches/projects_controller_patch.rb' + - 'lib/redmine_git_hosting/patches/user_patch.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/CompareWithBlock: + Exclude: + - 'lib/redmine_git_hosting/patches/project_patch.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/Detect: + Exclude: + - 'lib/redmine_git_hosting/gitolite_handlers/ssh_keys/base.rb' + - 'lib/redmine_git_hosting/plugins/gitolite_plugin.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'app/use_cases/repositories/build_payload.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'app/use_cases/repositories/build_payload.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/config/gitolite_infos.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Performance/ReverseEach: + Exclude: + - 'lib/redmine_git_hosting/gitolite_wrappers/projects/common.rb' + - 'lib/redmine_git_hosting/patches/projects_controller_patch.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/SortReverse: + Exclude: + - 'lib/redmine_git_hosting/recycle_bin/item_base.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/StringInclude: + Exclude: + - 'app/use_cases/repositories/build_payload.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/Date: + Exclude: + - 'app/reports/report_helper.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforceForPrefixed. +Rails/Delegate: + Exclude: + - 'app/models/repository/xitolite.rb' + - 'lib/redmine_git_hosting/cache.rb' + - 'lib/redmine_git_hosting/recycle_bin.rb' + +# Offense count: 45 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. +# Whitelist: find_by_sql +# AllowedMethods: find_by_sql +# AllowedReceivers: Gem::Specification +Rails/DynamicFindBy: + Enabled: false + +# Offense count: 9 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/InverseOf: + Exclude: + - 'app/models/repository/xitolite.rb' + - 'app/models/repository_protected_branche.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Rails/NegateInclude: + Exclude: + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/global/disable_rw_access.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/global/enable_rw_access.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Exclude: + - 'lib/redmine_git_hosting/config/base.rb' + +# Offense count: 5 +Rails/OutputSafety: + Exclude: + - 'app/helpers/gitolite_plugin_settings_helper.rb' + - 'app/presenters/repository_presenter.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Rails/Pluck: + Exclude: + - 'app/reports/repository_contributors_stats.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/Presence: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'app/use_cases/repository_mirrors/push.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/repositories/delete_repository.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/Rakefile, **/*.rake +Rails/RakeEnvironment: + Exclude: + - 'lib/tasks/redmine_git_hosting.rake' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/cache/abstract_cache.rb' + - 'lib/redmine_git_hosting/plugins/extenders/readme_creator.rb' + +# Offense count: 2 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/UniqueValidationWithoutIndex: + Exclude: + - 'app/models/gitolite_public_key.rb' + - 'app/models/repository_protected_branche.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/Validation: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/WhereEquals: + Exclude: + - 'app/reports/repository_commits_stats.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Security/YAMLLoad: + Exclude: + - 'spec/support/global_helpers.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'lib/redmine_git_hosting/error.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/ssh_keys/base.rb' + - 'lib/redmine_git_hosting/gitolite_params/global_params.rb' + - 'lib/redmine_git_hosting/gitolite_params/mailer_params.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/base.rb' + - 'lib/redmine_git_hosting/recycle_bin/item_base.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/redmine_git_hosting/git_access_status.rb' + +# Offense count: 9 +# Configuration parameters: AllowedChars. +Style/AsciiComments: + Exclude: + - 'app/models/gitolite_public_key.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowOnConstant. +Style/CaseEquality: + Exclude: + - 'app/helpers/repository_mirrors_helper.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/CaseLikeIf: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/config/gitolite_infos.rb' + - 'lib/redmine_git_hosting/plugins/sweepers/repository_deletor.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'app/models/repository/xitolite.rb' + - 'app/models/repository_git_config_key/git_config.rb' + - 'app/models/repository_git_config_key/option.rb' + - 'lib/redmine_git_hosting/plugins/extenders/base_extender.rb' + - 'lib/redmine_git_hosting/plugins/extenders/branch_updater.rb' + - 'lib/redmine_git_hosting/plugins/extenders/config_key_deletor.rb' + - 'lib/redmine_git_hosting/plugins/extenders/git_annex_creator.rb' + - 'lib/redmine_git_hosting/plugins/extenders/readme_creator.rb' + - 'lib/redmine_git_hosting/plugins/gitolite_plugin.rb' + - 'lib/redmine_git_hosting/plugins/sweepers/base_sweeper.rb' + - 'lib/redmine_git_hosting/plugins/sweepers/repository_deletor.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'app/models/protected_branches_member.rb' + - 'app/models/repository_protected_branche.rb' + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'lib/redmine_git_hosting/patches/project_patch.rb' + +# Offense count: 3 +Style/ClassVars: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/redmine_git_hosting/config/gitolite_access.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerBackticks. +# SupportedStyles: backticks, percent_x, mixed +Style/CommandLiteral: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_config.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + - 'lib/tasks/ci_tools.rake' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Keywords. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'app/models/concerns/gitolitable/cache.rb' + - 'lib/redmine_git_hosting/patches/grack_git_patch.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/redmine_git_hosting/config/gitolite_access.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + - 'spec/support/global_helpers.rb' + +# Offense count: 3 +Style/DocumentDynamicEvalDefinition: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EachWithObject: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/redmine_git_hosting/config/gitolite_infos.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/hrack/lib/hrack/server.rb' + +# Offense count: 3 +Style/EvalWithLocation: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 16 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + - 'app/services/redmine_hooks/github_issues_sync.rb' + - 'app/use_cases/repository_protected_branches/member_manager.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/git_access.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/gitolite_wrapper.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/base.rb' + - 'lib/redmine_git_hosting/patches/grack_auth_patch.rb' + - 'lib/redmine_git_hosting/patches/project_patch.rb' + - 'lib/redmine_git_hosting/patches/projects_controller_patch.rb' + - 'lib/redmine_git_hosting/patches/setting_patch.rb' + - 'lib/redmine_git_hosting/validators.rb' + +# Offense count: 2 +Style/IdenticalConditionalBranches: + Exclude: + - 'lib/tasks/migration_tools.rake' + +# Offense count: 6 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + - 'lib/hrack/lib/hrack/server.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/global/enable_rw_access.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/IfUnlessModifierOfIfUnless: + Exclude: + - 'lib/redmine_git_hosting/plugins/extenders/readme_creator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/cache/memcached.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'lib/hrack/lib/hrack/server.rb' + +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Autocorrect. +# SupportedStyles: module_function, extend_self, forbidden +Style/ModuleFunction: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'app/models/concerns/gitolitable/config.rb' + - 'lib/redmine_git_hosting/plugins/extenders/readme_creator.rb' + +# Offense count: 30 +# Cop supports --auto-correct. +Style/MultilineWhenThen: + Exclude: + - 'db/migrate/20130807223227_migrate_parameters.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Style/MultipleComparison: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_custom_hook.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/patches/grack_git_patch.rb' + - 'spec/support/flat_organization.rb' + - 'spec/support/hierarchical_organisation.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'app/models/repository_git_config_key/git_config.rb' + - 'lib/hrack/lib/hrack/server.rb' + - 'lib/redmine_git_hosting/config.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + - 'lib/redmine_git_hosting/recycle_bin/item_base.rb' + - 'lib/redmine_git_hosting/utils/git.rb' + - 'lib/redmine_git_hosting/validators.rb' + - 'spec/helpers/gitolite_public_keys_helper_spec.rb' + - 'spec/models/repository_deployment_credential_spec.rb' + - 'spec/models/repository_mirror_spec.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'app/reports/repository_contributors_stats.rb' + - 'app/use_cases/repositories/build_payload.rb' + - 'lib/hrack/lib/hrack/server.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +Style/NegatedIfElseCondition: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_http_helper.rb' + - 'db/migrate/20091119162426_set_mirror_role_permissions.rb' + - 'db/migrate/20120521000010_set_post_receive_url_role_permissions.rb' + - 'db/migrate/20120803043256_create_deployment_credentials.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/repositories/add_repository.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/repositories/update_repository.rb' + - 'lib/redmine_git_hosting/plugins/extenders/git_annex_creator.rb' + - 'lib/redmine_git_hosting/recycle_bin/deletable_item.rb' + - 'lib/redmine_git_hosting/utils/http.rb' + - 'lib/tasks/migration_tools.rake' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedWhile: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NestedTernaryOperator: + Exclude: + - 'app/reports/report_helper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/config/base.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Exclude: + - 'lib/redmine_git_hosting/gitolite_params/mailer_params.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/plugins/extenders/readme_creator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 6 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/helpers/git_hosting_helper.rb' + - 'lib/redmine_git_hosting/commands/sudo.rb' + - 'lib/redmine_git_hosting/config/base.rb' + - 'lib/redmine_git_hosting/config/gitolite_access.rb' + - 'lib/redmine_git_hosting/git_access.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. +Style/ParenthesesAroundCondition: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_config.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + - 'lib/tasks/ci_tools.rake' + - 'spec/models/repository_mirror_spec.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + EnforcedStyle: exploded + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'app/models/gitolite_public_key.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/commands/git.rb' + - 'lib/redmine_git_hosting/commands/sudo.rb' + - 'lib/redmine_git_hosting/utils/crypto.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantAssignment: + Exclude: + - 'lib/redmine_git_hosting/utils/crypto.rb' + - 'lib/redmine_git_hosting/utils/ssh.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/config/gitolite_config_tests.rb' + - 'lib/redmine_git_hosting/config/gitolite_infos.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/gitolite_wrapper.rb' + - 'lib/redmine_git_hosting/recycle_bin/restorable_item.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantInterpolation: + Exclude: + - 'app/use_cases/repository_mirrors/push.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'contrib/hooks/post-receive/lib/git_hosting_config.rb' + - 'lib/redmine_git_hosting/config/base.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantRegexpCharacterClass: + Exclude: + - 'lib/redmine_git_hosting/validators.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Exclude: + - 'db/migrate/20111220055819_add_settings_to_plugin_2.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/utils/crypto.rb' + - 'lib/redmine_git_hosting/validators.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'app/use_cases/repository_mirrors/push.rb' + - 'lib/hrack/lib/hrack/server.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/gitolite_wrappers/global/disable_rw_access.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'lib/hrack/lib/hrack/server.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'app/models/concerns/gitolitable/cache.rb' + - 'app/reports/repository_contributors_stats.rb' + - 'app/use_cases/repositories/build_payload.rb' + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/config/gitolite_access.rb' + - 'lib/redmine_git_hosting/patches/grack_auth_patch.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + - 'lib/redmine_git_hosting/recycle_bin/item_base.rb' + - 'lib/redmine_git_hosting/utils/crypto.rb' + - 'lib/redmine_git_hosting/utils/git.rb' + - 'lib/redmine_git_hosting/validators.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'app/models/gitolite_public_key.rb' + - 'app/models/repository_mirror.rb' + - 'lib/redmine_git_hosting/commands/sudo.rb' + - 'lib/redmine_git_hosting/config/base.rb' + - 'lib/redmine_git_hosting/config/gitolite_base.rb' + - 'lib/redmine_git_hosting/config/gitolite_storage.rb' + +# Offense count: 37 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/redmine_git_hosting/patches/project_patch.rb' + - 'lib/redmine_git_hosting/patches/repositories_controller_patch.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +Style/StringConcatenation: + Exclude: + - 'app/helpers/repository_deployment_credentials_helper.rb' + - 'app/models/gitolite_public_key.rb' + - 'app/use_cases/repository_mirrors/push.rb' + - 'lib/redmine_git_hosting/cache.rb' + - 'lib/redmine_git_hosting/cache/memcached.rb' + - 'lib/redmine_git_hosting/commands/sudo.rb' + - 'lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb' + - 'lib/redmine_git_hosting/hooks.rb' + - 'lib/redmine_git_hosting/mirror_keys_installer.rb' + - 'lib/redmine_git_hosting/shell_redirector.rb' + - 'spec/lib/redmine_git_hosting/config_spec.rb' + - 'spec/lib/redmine_git_hosting/utils/git_spec.rb' + - 'spec/models/repository_git_config_key/git_config_spec.rb' + - 'spec/models/repository_git_config_key/option_spec.rb' + - 'spec/services/redmine_hooks/call_webservices_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'app/models/concerns/gitolitable/validations.rb' + - 'app/use_cases/repository_mirrors/push.rb' + - 'lib/redmine_git_hosting/commands/sudo.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'lib/redmine_git_hosting/utils/exec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'app/models/concerns/gitolitable/users.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/redmine/scm/adapters/xitolite_adapter.rb' + - 'lib/redmine_git_hosting/gitolite_hooks.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/WhileUntilModifier: + Exclude: + - 'lib/redmine_git_hosting/shell_redirector.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 diff --git a/.slim-lint.yml b/.slim-lint.yml new file mode 100644 index 00000000000..54689e639d3 --- /dev/null +++ b/.slim-lint.yml @@ -0,0 +1,40 @@ +linters: + LineLength: + max: 140 + RuboCop: + ignored_cops: + - Layout/ArgumentAlignment + - Layout/ArrayAlignment + - Layout/BlockEndNewline + - Layout/EmptyLineAfterGuardClause + - Layout/HashAlignment + - Layout/IndentationConsistency + - Layout/IndentationWidth + - Layout/IndentFirstArgument + - Layout/IndentFirstArrayElement + - Layout/IndentFirstHashElement + - Layout/MultilineArrayBraceLayout + - Layout/MultilineAssignmentLayout + - Layout/MultilineBlockLayout + - Layout/MultilineHashBraceLayout + - Layout/MultilineMethodCallBraceLayout + - Layout/MultilineMethodCallIndentation + - Layout/MultilineMethodDefinitionBraceLayout + - Layout/MultilineOperationIndentation + - Layout/TrailingBlankLines + - Layout/TrailingEmptyLines + - Layout/TrailingWhitespace + - Lint/BlockAlignment + - Lint/EndAlignment + - Lint/Void + - Metrics/BlockLength + - Metrics/BlockNesting + - Metrics/LineLength + - Naming/FileName + - Rails/OutputSafety + - Style/ConditionalAssignment + - Style/FrozenStringLiteralComment + - Style/IdenticalConditionalBranches + - Style/IfUnlessModifier + - Style/Next + - Style/WhileUntilModifier diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0480e2d4b5b..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: ruby -sudo: required -cache: bundler -rvm: - - 2.6 - - 2.5 -gemfile: - - Gemfile -services: - - mysql - - postgresql -env: - global: - - REDMINE_LANG=en - - MYSQL_DATABASE=redmine - - MYSQL_HOST=127.0.0.1 - - MYSQL_PORT=3306 - - MYSQL_USER=root - - MYSQL_PASSWORD= - - POSTGRES_DATABASE=redmine - - POSTGRES_USER=postgres - matrix: - - REDMINE_VERSION=4.0-stable DATABASE_ADAPTER=mysql USE_SVN=true - - REDMINE_VERSION=4.0-stable DATABASE_ADAPTER=postgresql USE_SVN=true -before_install: - - cd ../.. - - sudo apt-get update -qq - - ./jbox-web/redmine_git_hosting/contrib/travis/install_redmine.sh - - cd redmine - - echo $(pwd) - - export BUNDLE_GEMFILE=$PWD/Gemfile -before_script: - - echo $(pwd) - - mysql -e 'create database redmine;' - - psql -c 'create database redmine;' -U postgres - - bundle exec rake generate_secret_token - - bundle exec rake db:migrate - - bundle exec rake redmine:load_default_data - - bundle exec rake redmine:plugins:migrate - - bundle exec rake db:test:prepare -script: - - bundle exec rake redmine_git_hosting:ci:all diff --git a/CHANGELOG.md b/CHANGELOG.md index 4185fbd21b7..e4efa375f7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,17 @@ ## CHANGELOG -### 4.0.0 +### 4.0.3 + +- Redmine 4.1 support +- Dashboard support for Repository URLs +- Dropped archived repository view +- switch CI from Travis to Github Actions +- add Basic Auth support for post_receive_urls +- add post_receive_url :post empty support +- add logging to journal, if configured for Redmine (see https://github.com/theforeman/journald-logger) +### 4.0.0 +https://github.com/theforeman/journald-logger * compatible with Redmine 4 (drop Redmine 3.x support) * drop redmine_bootstrap_kit required plugin * requires additionals plugin for latest fontawesome, slim and deface support -> and better maintenance diff --git a/Gemfile b/Gemfile index 8e7d147b2d7..7ae82ea7519 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +source 'https://rubygems.org' + # Gitolite Admin repository management gem 'gitolite-rugged', git: 'https://github.com/jbox-web/gitolite-rugged.git', tag: '1.2.0' @@ -8,20 +10,21 @@ gem 'gitlab-grack', '~> 2.0.0', git: 'https://github.com/jbox-web/grack.git', re gem 'dalli' # Redis client for GitCache -gem 'redis' gem 'hiredis' +gem 'redis' # Markdown rendering +gem 'deckar01-task_list' gem 'escape_utils' gem 'html-pipeline' gem 'rinku' # Syntaxic coloration +gem 'asciidoctor' +gem 'creole' gem 'github-markup' -gem 'RedCloth' gem 'org-ruby' -gem 'creole' -gem 'asciidoctor' +gem 'RedCloth' # Rack parser for Hrack gem 'rack-parser', require: 'rack/parser' @@ -31,9 +34,9 @@ gem 'sidekiq' gem 'sshkey' group :development, :test do + gem 'rails-controller-testing' gem 'rspec' gem 'rspec-rails', '~> 3.5', '>= 3.5.2' - gem 'rails-controller-testing' gem 'shoulda', '~> 3.5.0' gem 'shoulda-context' @@ -42,15 +45,11 @@ group :development, :test do gem 'database_cleaner' gem 'factory_bot_rails', '< 5.0' - gem 'rubocop', require: false - gem 'rubocop-rspec' - # Publish to CodeClimate gem 'codeclimate-test-reporter', require: false end group :development do - gem 'brakeman' gem 'bullet' gem 'spring' gem 'spring-commands-rspec' diff --git a/README.md b/README.md index 473a5d1f576..9e4e8dcd041 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ ## ![logo](https://raw.github.com/jbox-web/redmine_git_hosting/gh-pages/images/git_logo.png) Redmine Git Hosting Plugin -[![GitHub license](https://img.shields.io/github/license/jbox-web/redmine_git_hosting.svg)](https://github.com/jbox-web/redmine_git_hosting/blob/master/LICENSE) +[![GitHub license](https://img.shields.io/github/license/jbox-web/redmine_git_hosting.svg)](https://github.com/jbox-web/redmine_git_hosting/blob/devel/LICENSE) [![GitHub release](https://img.shields.io/github/release/jbox-web/redmine_git_hosting.svg)](https://github.com/jbox-web/redmine_git_hosting/releases/latest) -[![Code Climate](https://codeclimate.com/github/jbox-web/redmine_git_hosting.png)](https://codeclimate.com/github/jbox-web/redmine_git_hosting) -[![Build Status](https://travis-ci.com/jbox-web/redmine_git_hosting.svg?branch=master)](https://travis-ci.com/jbox-web/redmine_git_hosting) +[![Brakeman security tests](../../workflows/Run%20Brakeman/badge.svg)](../../actions?query=workflow%3A%22Run+Brakeman%22) +[![Coding standards](../../workflows/Run%20Linters/badge.svg)](../../actions?query=workflow%3A%22Run+Linters%22) +[![Tests](../../workflows/Test/badge.svg)](../../actions?query=workflow%3ATest) ### A Redmine plugin which makes configuring your own Git hosting easy ;) @@ -19,7 +20,7 @@ Read the documentation and more on the [project's website](http://redmine-git-ho ## Contributors -A big thank to [them](https://github.com/jbox-web/redmine_git_hosting/blob/master/AUTHORS) for their contribution! +A big thank to [them](https://github.com/jbox-web/redmine_git_hosting/blob/devel/AUTHORS) for their contribution! ## Contribute diff --git a/app/controllers/archived_repositories_controller.rb b/app/controllers/archived_repositories_controller.rb index ce9d33b6502..f2539d18874 100644 --- a/app/controllers/archived_repositories_controller.rb +++ b/app/controllers/archived_repositories_controller.rb @@ -5,7 +5,8 @@ class ArchivedRepositoriesController < RepositoriesController before_action :can_view_archived_projects def index - @archived_projects = Project.where("status = #{Project::STATUS_ARCHIVED}").includes(:repositories) + @archived_projects = Project.where(status: Project::STATUS_ARCHIVED) + .includes(:repositories) end private diff --git a/app/controllers/concerns/xitolite_repository_finder.rb b/app/controllers/concerns/xitolite_repository_finder.rb index 04ecd5ebf25..2d65f2b0621 100644 --- a/app/controllers/concerns/xitolite_repository_finder.rb +++ b/app/controllers/concerns/xitolite_repository_finder.rb @@ -2,30 +2,28 @@ module XitoliteRepositoryFinder extend ActiveSupport::Concern def find_xitolite_repository - begin - @repository = Repository::Xitolite.find(find_repository_param) - rescue ActiveRecord::RecordNotFound => e - render_404 - else - @project = @repository.project - render_404 if @project.nil? - end + @repository = Repository::Xitolite.find(find_repository_param) + rescue ActiveRecord::RecordNotFound => e + render_404 + else + @project = @repository.project + render_404 if @project.nil? end - def find_xitolite_repository_by_path - repo_path = params[:repo_path] + '.git' - repository = Repository::Xitolite.find_by_path(repo_path, loose: true) + repo_path = "#{params[:repo_path]}.git" + repository = Repository::Xitolite.find_by_path repo_path, loose: true if repository.nil? - RedmineGitHosting.logger.error("GoRedirector : repository not found at path : '#{repo_path}', exiting !") + RedmineGitHosting.logger.error "GoRedirector : repository not found at path : '#{repo_path}'," \ + ' exiting!' render_404 elsif !repository.go_access_available? - RedmineGitHosting.logger.error("GoRedirector : GoAccess is disabled for this repository '#{repository.gitolite_repository_name}', exiting !") + RedmineGitHosting.logger.error "GoRedirector : GoAccess is disabled for this repository '#{repository.gitolite_repository_name}'," \ + ' exiting!' render_403 else RedmineGitHosting.logger.info("GoRedirector : access granted for repository '#{repository.gitolite_repository_name}'") @repository = repository end end - end diff --git a/app/controllers/download_git_revision_controller.rb b/app/controllers/download_git_revision_controller.rb index dd5856d1b2b..dcf6b0bea67 100644 --- a/app/controllers/download_git_revision_controller.rb +++ b/app/controllers/download_git_revision_controller.rb @@ -1,5 +1,4 @@ class DownloadGitRevisionController < ApplicationController - include XitoliteRepositoryFinder before_action :find_xitolite_repository @@ -7,51 +6,41 @@ class DownloadGitRevisionController < ApplicationController before_action :set_download before_action :validate_download - helper :bootstrap_kit + helper :git_hosting def index - begin - send_data(@download.content, filename: @download.filename, type: @download.content_type) - rescue => e - flash.now[:error] = l(:git_archive_timeout, timeout: e.output) - render_404 - end + send_data(@download.content, filename: @download.filename, type: @download.content_type) + rescue => e + flash.now[:error] = l(:git_archive_timeout, timeout: e.output) + render_404 end - private + def find_repository_param + params[:id] + end - def find_repository_param - params[:id] - end - - - def can_download_git_revision - render_403 unless User.current.allowed_to_download?(@repository) - end - - - def set_download - @download = Repositories::DownloadRevision.new(@repository, download_revision, download_format) - end - - - def download_revision - @download_revision ||= (params[:rev] || 'master') - end + def can_download_git_revision + render_403 unless User.current.allowed_to_download?(@repository) + end + def set_download + @download = Repositories::DownloadRevision.new(@repository, download_revision, download_format) + end - def download_format - @download_format ||= (params[:download_format] || 'tar') - end + def download_revision + @download_revision ||= (params[:rev] || 'master') + end + def download_format + @download_format ||= (params[:download_format] || 'tar') + end - def validate_download - if !@download.valid_commit? - flash.now[:error] = l(:error_download_revision_no_such_commit, commit: download_revision) - render_404 - end - end + def validate_download + return if @download.valid_commit? + flash.now[:error] = l(:error_download_revision_no_such_commit, commit: download_revision) + render_404 + end end diff --git a/app/controllers/gitolite_public_keys_controller.rb b/app/controllers/gitolite_public_keys_controller.rb index 59e5dd71aaa..a1a446ccaa1 100644 --- a/app/controllers/gitolite_public_keys_controller.rb +++ b/app/controllers/gitolite_public_keys_controller.rb @@ -6,11 +6,11 @@ class GitolitePublicKeysController < ApplicationController before_action :find_gitolite_public_key, only: [:destroy] helper :gitolite_public_keys - helper :bootstrap_kit + helper :git_hosting def index - @gitolite_user_keys = @user.gitolite_public_keys.user_key.order('title ASC, created_at ASC') - @gitolite_deploy_keys = @user.gitolite_public_keys.deploy_key.order('title ASC, created_at ASC') + @gitolite_user_keys = @user.gitolite_public_keys.user_key.sorted + @gitolite_deploy_keys = @user.gitolite_public_keys.deploy_key.sorted end def create diff --git a/app/controllers/go_redirector_controller.rb b/app/controllers/go_redirector_controller.rb index d1a5eb6ae70..d9a6ab3b95a 100644 --- a/app/controllers/go_redirector_controller.rb +++ b/app/controllers/go_redirector_controller.rb @@ -1,5 +1,4 @@ class GoRedirectorController < ApplicationController - include XitoliteRepositoryFinder # prevents login action to be filtered by check_if_login_required application scope filter @@ -7,8 +6,5 @@ class GoRedirectorController < ApplicationController before_action :find_xitolite_repository_by_path - - def index - end - + def index; end end diff --git a/app/controllers/redmine_git_hosting_controller.rb b/app/controllers/redmine_git_hosting_controller.rb index 6e48fdd3934..7cb1e4723cb 100644 --- a/app/controllers/redmine_git_hosting_controller.rb +++ b/app/controllers/redmine_git_hosting_controller.rb @@ -8,7 +8,7 @@ class RedmineGitHostingController < ApplicationController layout(proc { |controller| controller.request.xhr? ? false : 'base' }) - helper :bootstrap_kit + helper :git_hosting def show respond_to do |format| diff --git a/app/controllers/repository_deployment_credentials_controller.rb b/app/controllers/repository_deployment_credentials_controller.rb index 13b98adee2b..e3f01852bba 100644 --- a/app/controllers/repository_deployment_credentials_controller.rb +++ b/app/controllers/repository_deployment_credentials_controller.rb @@ -9,7 +9,7 @@ class RepositoryDeploymentCredentialsController < RedmineGitHostingController helper :gitolite_public_keys def index - @repository_deployment_credentials = @repository.deployment_credentials.all + @repository_deployment_credentials = @repository.deployment_credentials.sorted render layout: false end @@ -25,7 +25,7 @@ def new def create @credential = build_new_credential - return unless @credential.save + return render action: 'new' unless @credential.save flash[:notice] = l(:notice_deployment_credential_created) call_use_case_and_redirect @@ -33,7 +33,7 @@ def create def update @credential.safe_attributes = params[:repository_deployment_credential] - return unless @credential.save + return render action: 'edit' unless @credential.save flash[:notice] = l(:notice_deployment_credential_updated) call_use_case_and_redirect @@ -84,15 +84,16 @@ def find_key def find_all_keys # display create_with_key view. Find preexisting keys to offer to user - @user_keys = User.current.gitolite_public_keys.deploy_key.order('title ASC') + @user_keys = User.current.gitolite_public_keys.deploy_key.order(:title) @disabled_keys = @repository.deployment_credentials.map(&:gitolite_public_key) - @other_keys = [] + @other_keys = [] # Admin can use other's deploy keys as well - @other_keys = other_deployment_keys if User.current.admin? + @other_keys = other_deployment_keys if User.current.admin? end def other_deployment_keys - users_allowed_to_create_deployment_keys.map { |user| user.gitolite_public_keys.deploy_key.order('title ASC') }.flatten + keys = users_allowed_to_create_deployment_keys.map { |user| user.gitolite_public_keys.deploy_key.order(:title) } + keys.flatten end def users_allowed_to_create_deployment_keys @@ -101,7 +102,7 @@ def users_allowed_to_create_deployment_keys def call_use_case(opts = {}) options = opts.merge(message: "Update deploy keys for repository : '#{@repository.gitolite_repository_name}'") - gitolite_accessor.update_repository(@repository, options) + gitolite_accessor.update_repository @repository, options end def build_new_credential diff --git a/app/controllers/repository_git_config_keys_controller.rb b/app/controllers/repository_git_config_keys_controller.rb index 91d1abe83e3..87de8eef223 100644 --- a/app/controllers/repository_git_config_keys_controller.rb +++ b/app/controllers/repository_git_config_keys_controller.rb @@ -19,7 +19,7 @@ def new def create @git_config_key = @repository.send(key_type).new @git_config_key.safe_attributes = params[:repository_git_config_key] - return unless @git_config_key.save + return render action: 'new' unless @git_config_key.save flash[:notice] = l(:notice_git_config_key_created) call_use_case_and_redirect @@ -27,7 +27,7 @@ def create def update @git_config_key.safe_attributes = params[:repository_git_config_key] - return unless @git_config_key.save + return render action: 'edit' unless @git_config_key.save flash[:notice] = l(:notice_git_config_key_updated) options = @git_config_key.key_has_changed? ? { delete_git_config_key: @git_config_key.old_key } : {} diff --git a/app/controllers/repository_git_extras_controller.rb b/app/controllers/repository_git_extras_controller.rb index ec0f22bd012..aab22801d70 100644 --- a/app/controllers/repository_git_extras_controller.rb +++ b/app/controllers/repository_git_extras_controller.rb @@ -33,7 +33,6 @@ def move return unless request.post? @move_repository_form = MoveRepositoryForm.new(@repository) - return unless @move_repository_form.submit(params[:repository_mover]) redirect_to settings_project_path(@repository.project, tab: 'repositories') diff --git a/app/controllers/repository_mirrors_controller.rb b/app/controllers/repository_mirrors_controller.rb index ba746282982..4159b8eab59 100644 --- a/app/controllers/repository_mirrors_controller.rb +++ b/app/controllers/repository_mirrors_controller.rb @@ -7,7 +7,7 @@ class RepositoryMirrorsController < RedmineGitHostingController helper :additionals_clipboardjs def index - @repository_mirrors = @repository.mirrors.all + @repository_mirrors = @repository.mirrors.sorted render_with_api end @@ -18,7 +18,7 @@ def new def create @mirror = @repository.mirrors.new @mirror.safe_attributes = params[:repository_mirror] - return unless @mirror.save + return render action: 'new' unless @mirror.save flash[:notice] = l(:notice_mirror_created) render_js_redirect @@ -26,7 +26,7 @@ def create def update @mirror.safe_attributes = params[:repository_mirror] - return unless @mirror.save + return render action: 'edit' unless @mirror.save flash[:notice] = l(:notice_mirror_updated) render_js_redirect diff --git a/app/controllers/repository_post_receive_urls_controller.rb b/app/controllers/repository_post_receive_urls_controller.rb index a16df05f1de..fb0689c5c67 100644 --- a/app/controllers/repository_post_receive_urls_controller.rb +++ b/app/controllers/repository_post_receive_urls_controller.rb @@ -3,9 +3,10 @@ class RepositoryPostReceiveUrlsController < RedmineGitHostingController before_action :find_repository_post_receive_url, except: %i[index new create] accept_api_auth :index, :show + # skip_before_action :verify_authenticity_token, only: %i[create update] def index - @repository_post_receive_urls = @repository.post_receive_urls.all + @repository_post_receive_urls = @repository.post_receive_urls.sorted render_with_api end @@ -16,7 +17,7 @@ def new def create @post_receive_url = @repository.post_receive_urls.new @post_receive_url.safe_attributes = params[:repository_post_receive_url] - return unless @post_receive_url.save + return render action: 'new' unless @post_receive_url.save flash[:notice] = l(:notice_post_receive_url_created) render_js_redirect @@ -24,7 +25,7 @@ def create def update @post_receive_url.safe_attributes = params[:repository_post_receive_url] - return unless @post_receive_url.save + return render action: 'edit' unless @post_receive_url.save flash[:notice] = l(:notice_post_receive_url_updated) render_js_redirect diff --git a/app/controllers/repository_protected_branches_controller.rb b/app/controllers/repository_protected_branches_controller.rb index 23e2365c8b4..58bb2e6908f 100644 --- a/app/controllers/repository_protected_branches_controller.rb +++ b/app/controllers/repository_protected_branches_controller.rb @@ -7,7 +7,7 @@ class RepositoryProtectedBranchesController < RedmineGitHostingController accept_api_auth :index, :show def index - @repository_protected_branches = @repository.protected_branches.all + @repository_protected_branches = @repository.protected_branches.sorted render_with_api end @@ -18,7 +18,7 @@ def new def create @protected_branch = @repository.protected_branches.new @protected_branch.safe_attributes = params[:repository_protected_branche] - return unless @protected_branch.save + return render action: 'new' unless @protected_branch.save check_members flash[:notice] = l(:notice_protected_branch_created) @@ -27,7 +27,7 @@ def create def update @protected_branch.safe_attributes = params[:repository_protected_branche] - return unless @protected_branch.save + return render action: 'edit' unless @protected_branch.save check_members flash[:notice] = l(:notice_protected_branch_updated) diff --git a/app/forms/plugin_settings_validation/gitolite_access_config.rb b/app/forms/plugin_settings_validation/gitolite_access_config.rb index f0d64ae1702..e9b184c088f 100644 --- a/app/forms/plugin_settings_validation/gitolite_access_config.rb +++ b/app/forms/plugin_settings_validation/gitolite_access_config.rb @@ -8,7 +8,6 @@ module GitoliteAccessConfig :http_server_domain, :https_server_domain, :http_server_subdir, - :show_repositories_url, :gitolite_daemon_by_default, :gitolite_http_by_default @@ -23,7 +22,6 @@ module GitoliteAccessConfig validates :http_server_domain, presence: true, format: { with: RedmineGitHosting::Validators::DOMAIN_REGEX } validates :https_server_domain, format: { with: RedmineGitHosting::Validators::DOMAIN_REGEX }, allow_blank: true - validates :show_repositories_url, presence: true, inclusion: { in: RedmineGitHosting::Validators::BOOLEAN_FIELDS } validates :gitolite_daemon_by_default, presence: true, inclusion: { in: RedmineGitHosting::Validators::BOOLEAN_FIELDS } validates :gitolite_http_by_default, presence: true, inclusion: { in: %w[0 1 2 3] }, numericality: { only_integer: true } diff --git a/app/forms/plugin_settings_validation/gitolite_config.rb b/app/forms/plugin_settings_validation/gitolite_config.rb index 242e5f472f6..9d444a359a9 100644 --- a/app/forms/plugin_settings_validation/gitolite_config.rb +++ b/app/forms/plugin_settings_validation/gitolite_config.rb @@ -31,7 +31,7 @@ module GitoliteConfig validates :gitolite_temp_dir, presence: true validates :gitolite_recycle_bin_expiration_time, presence: true, numericality: true - validates :gitolite_log_level, presence: true, inclusion: { in: RedmineGitHosting::Logger::LOG_LEVELS } + validates :gitolite_log_level, presence: true, inclusion: { in: RedmineGitHosting::FileLogger::LOG_LEVELS } validates :git_config_username, presence: true validates :git_config_email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP } diff --git a/app/forms/plugin_settings_validation/hooks_config.rb b/app/forms/plugin_settings_validation/hooks_config.rb index 28ee92f739a..4ebd1bba0c4 100644 --- a/app/forms/plugin_settings_validation/hooks_config.rb +++ b/app/forms/plugin_settings_validation/hooks_config.rb @@ -16,7 +16,7 @@ module HooksConfig validates :gitolite_overwrite_existing_hooks, presence: true, inclusion: { in: RedmineGitHosting::Validators::BOOLEAN_FIELDS } validates :gitolite_hooks_are_asynchronous, presence: true, inclusion: { in: RedmineGitHosting::Validators::BOOLEAN_FIELDS } validates :gitolite_hooks_debug, presence: true, inclusion: { in: RedmineGitHosting::Validators::BOOLEAN_FIELDS } - validates :gitolite_hooks_url, presence: true, format: { with: URI::regexp(%w[http https]) } + validates :gitolite_hooks_url, presence: true, format: { with: URI::DEFAULT_PARSER.make_regexp(%w[http https]) } end end end diff --git a/app/forms/plugin_settings_validation/ssh_config.rb b/app/forms/plugin_settings_validation/ssh_config.rb index e3ce75ca568..79c1d9e4cc9 100644 --- a/app/forms/plugin_settings_validation/ssh_config.rb +++ b/app/forms/plugin_settings_validation/ssh_config.rb @@ -19,14 +19,14 @@ module SshConfig self.gitolite_ssh_public_key = strip_value(gitolite_ssh_public_key) end - validates :gitolite_user, presence: true - validates :gitolite_server_host, presence: true - validates :gitolite_server_port, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 65_536 } - validates :gitolite_ssh_private_key, presence: true - validates :gitolite_ssh_public_key, presence: true + validates :gitolite_user, :gitolite_server_host, :gitolite_ssh_private_key, :gitolite_ssh_public_key, + presence: true + validates :gitolite_server_port, + presence: true, + numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 65_536 } validates_each :gitolite_ssh_private_key, :gitolite_ssh_public_key do |record, attr, value| - record.errors.add(attr, 'must exists on filesystem') unless File.exists?(value) + record.errors.add(attr, 'must exists on filesystem') unless File.exist? value end end end diff --git a/app/helpers/archived_repositories_helper.rb b/app/helpers/archived_repositories_helper.rb deleted file mode 100644 index fa9495dd9b3..00000000000 --- a/app/helpers/archived_repositories_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ArchivedRepositoriesHelper - - def link_to_revision2(revision, repository, options = {}) - repository = repository.repository if repository.is_a?(Project) - text = options.delete(:text) { format_revision(revision) } - rev = revision.respond_to?(:identifier) ? revision.identifier : revision - link_to( - h(text), - { controller: 'archived_repositories', action: 'revision', id: repository.project, repository_id: repository.identifier_param, rev: rev }, - title: l(:label_revision_id, format_revision(revision)) - ) - end - -end diff --git a/app/helpers/bootstrap_kit/ajax_helper.rb b/app/helpers/bootstrap_kit/ajax_helper.rb deleted file mode 100644 index af223916310..00000000000 --- a/app/helpers/bootstrap_kit/ajax_helper.rb +++ /dev/null @@ -1,33 +0,0 @@ -module BootstrapKit::AjaxHelper - def render_flash_messages_as_js(target = '#flash-messages', opts = {}) - js_render(target, render_flash_messages, opts).html_safe - end - - def js_render_template(target, template, opts = {}) - locals = opts.delete(:locals) { {} } - content = render(template: template, locals: locals) - js_render(target, content, opts) - end - - def js_render_partial(target, partial, opts = {}) - locals = opts.delete(:locals) { {} } - content = render(partial: partial, locals: locals) - js_render(target, content, opts) - end - - def js_render(target, content, opts = {}) - method = opts.delete(:method) { :inject } - "$('#{target}').#{js_rendering_method(method)}(\"#{escape_javascript(content)}\");\n".html_safe - end - - def js_rendering_method(method) - case method - when :append - 'append' - when :inject - 'html' - when :replace - 'replaceWith' - end - end -end diff --git a/app/helpers/bootstrap_kit/presenter_helper.rb b/app/helpers/bootstrap_kit/presenter_helper.rb deleted file mode 100644 index 53f47dee1c1..00000000000 --- a/app/helpers/bootstrap_kit/presenter_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module BootstrapKit::PresenterHelper - def present(object, klass = nil, *args) - klass ||= "#{object.class.base_class}Presenter".constantize - presenter = klass.new(object, self, *args) - yield presenter if block_given? - presenter - end -end diff --git a/app/helpers/bootstrap_kit_helper.rb b/app/helpers/bootstrap_kit_helper.rb deleted file mode 100644 index 2e360f1768a..00000000000 --- a/app/helpers/bootstrap_kit_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -module BootstrapKitHelper - include BootstrapKit::AjaxHelper - include BootstrapKit::PresenterHelper - - def bootstrap_load_base - stylesheet_link_tag('bootstrap_custom', plugin: 'redmine_git_hosting') + - bs_include_css('bootstrap_custom') - end - - def bootstrap_load_module(bs_module) - method = "load_bs_module_#{bs_module}" - send(method) - end - - def checked_image_with_exclamation(checked = true) - checked ? image_tag('toggle_check.png') : image_tag('exclamation.png') - end - - private - - def bs_include_js(js) - javascript_include_tag "bootstrap/#{js}", plugin: 'redmine_git_hosting' - end - - def bs_include_css(css) - stylesheet_link_tag "bootstrap/#{css}", plugin: 'redmine_git_hosting' - end - - def load_bs_module_alerts - bs_include_js('bootstrap_alert') + - bs_include_js('bootstrap_alert_helper') + - bs_include_js('bootstrap_transitions') + - bs_include_css('bootstrap_alert') + - bs_include_css('bootstrap_animations') + - bs_include_css('bootstrap_close') - end - - def load_bs_module_label - bs_include_css('bootstrap_label') - end - - def load_bs_module_modals - bs_include_js('bootstrap_modal') - end - - def load_bs_module_sortable - bs_include_js('bootstrap_sortable_helper') - end - - def load_bs_module_tables - bs_include_css('bootstrap_tables') - end - - def load_bs_module_tooltip - bs_include_js('bootstrap_tooltip') + - bs_include_js('bootstrap_tooltip_helper') + - bs_include_css('bootstrap_tooltip') - end -end diff --git a/app/helpers/extend_projects_helper.rb b/app/helpers/extend_projects_helper.rb index ba55d138a87..1f7625e7a50 100644 --- a/app/helpers/extend_projects_helper.rb +++ b/app/helpers/extend_projects_helper.rb @@ -13,69 +13,69 @@ def render_feature(repository, feature) base_label << label base_label << "(#{l(:label_disabled)})" unless enabled - content_tag(:i, '', title: base_label.join(' '), class: base_class) + tag.i '', title: base_label.join(' '), class: base_class end def deployment_credentials_feature(repository) - label = l(:label_deployment_credentials) + label = l :label_deployment_credentials css_class = 'fas fa-lock' - enabled = repository.deployment_credentials.active.any? + enabled = repository.deployment_credentials.active.any? [label, css_class, enabled] end def post_receive_urls_feature(repository) - label = l(:label_post_receive_urls) + label = l :label_post_receive_urls css_class = 'fas fa-external-link-alt' - enabled = repository.post_receive_urls.active.any? + enabled = repository.post_receive_urls.active.any? [label, css_class, enabled] end def mirrors_feature(repository) - label = l(:label_repository_mirrors) + label = l :label_repository_mirrors css_class = 'fas fa-cloud-upload-alt' - enabled = repository.mirrors.active.any? + enabled = repository.mirrors.active.any? [label, css_class, enabled] end def git_daemon_feature(repository) - label = l(:label_git_daemon) + label = l :label_git_daemon css_class = 'fab fa-git' - enabled = repository.git_access_available? + enabled = repository.git_access_available? [label, css_class, enabled] end def git_http_feature(repository) - label = l(:label_smart_http) + label = l :label_smart_http css_class = 'fas fa-cloud-download-alt' - enabled = repository.smart_http_enabled? + enabled = repository.smart_http_enabled? [label, css_class, enabled] end def git_notify_feature(repository) - label = l(:label_git_notify) + label = l :label_git_notify css_class = 'fas fa-bullhorn' - enabled = repository.git_notification_enabled? + enabled = repository.git_notification_enabled? [label, css_class, enabled] end def protected_branch_feature(repository) - label = l(:label_protected_branch) + label = l :label_protected_branch css_class = 'fas fa-shield-alt' - enabled = repository.protected_branches_available? + enabled = repository.protected_branches_available? [label, css_class, enabled] end def git_annex_feature(repository) - label = l(:label_git_annex) + label = l :label_git_annex css_class = 'fas fa-cloud-upload-alt' - enabled = repository.git_annex_enabled? + enabled = repository.git_annex_enabled? [label, css_class, enabled] end def public_repo_feature(repository) - label = l(:label_public_repo) + label = l :label_public_repo css_class = 'fas fa-users' - enabled = repository.public_repo? + enabled = repository.public_repo? [label, css_class, enabled] end end diff --git a/app/helpers/extend_repositories_helper.rb b/app/helpers/extend_repositories_helper.rb index 592fc205e5d..c14159a3f73 100644 --- a/app/helpers/extend_repositories_helper.rb +++ b/app/helpers/extend_repositories_helper.rb @@ -1,6 +1,6 @@ module ExtendRepositoriesHelper - def encoding_field(form, repository) - content_tag(:p) do + def encoding_field(form, _repository) + tag.p do form.select( :path_encoding, [nil] + Setting::ENCODINGS, label: l(:field_scm_path_encoding) @@ -12,22 +12,22 @@ def available_download_format(repository, rev = nil) %w[zip tar tar.gz].map { |f| [f, download_git_revision_repository_path(repository, rev: rev, download_format: f)] } end - def create_readme_field(form, repository) + def create_readme_field(_form, repository) return unless repository.new_record? - content_tag(:p) do + tag.p do hidden_field_tag('repository[create_readme]', 'false', id: '') + - content_tag(:label, l(:label_init_repo_with_readme), for: 'repository_create_readme') + + tag.label(l(:label_init_repo_with_readme), for: 'repository_create_readme') + check_box_tag('repository[create_readme]', 'true', RedmineGitHosting::Config.init_repositories_on_create?) end end - def enable_git_annex_field(form, repository) + def enable_git_annex_field(_form, repository) return unless repository.new_record? - content_tag(:p) do + tag.p do hidden_field_tag('repository[enable_git_annex]', 'false', id: '') + - content_tag(:label, l(:label_init_repo_with_git_annex), for: 'repository_enable_git_annex') + + tag.label(l(:label_init_repo_with_git_annex), for: 'repository_enable_git_annex') + check_box_tag('repository[enable_git_annex]', 'true') end end @@ -37,10 +37,11 @@ def repository_branches_list(branches) end def render_repository_quick_jump(repository) - options = repository.project.repositories.map { |r| [r.redmine_name, edit_repository_path(r)] } - select_tag('repository_quick_jump_box', + options = repository.project.repositories.sort + options.map! { |r| [r.redmine_name, edit_repository_path(r)] } + select_tag 'repository_quick_jump_box', options_for_select(options, selected: edit_repository_path(repository)), - onchange: 'if (this.value != \'\') { window.location = this.value; }') + onchange: 'if (this.value != \'\') { window.location = this.value; }' end def link_to_repository(repo, current_repo) diff --git a/app/helpers/git_hosting_helper.rb b/app/helpers/git_hosting_helper.rb new file mode 100644 index 00000000000..fad102d57a0 --- /dev/null +++ b/app/helpers/git_hosting_helper.rb @@ -0,0 +1,31 @@ +module GitHostingHelper + def present(object, klass = nil, *args) + klass ||= "#{object.class.base_class}Presenter".constantize + presenter = klass.new(object, self, *args) + yield presenter if block_given? + presenter + end + + def checked_image_with_exclamation(checked = true) + checked ? image_tag('toggle_check.png') : image_tag('exclamation.png') + end + + def render_shell_text(text) + Redmine::SyntaxHighlighting.highlight_by_language text, 'shell' + end + + def gitolite_project_settings_tabs + tabs = [] + + tabs << { name: 'db', + action: :show, + partial: 'projects/settings/db', + label: :label_db } + + tabs << { name: 'db2', + action: :show, + partial: 'projects/settings/db', + label: :label_db } + tabs + end +end diff --git a/app/helpers/git_hosting_users_helper.rb b/app/helpers/git_hosting_users_helper.rb index 30d9db608aa..aa0b09bcb80 100644 --- a/app/helpers/git_hosting_users_helper.rb +++ b/app/helpers/git_hosting_users_helper.rb @@ -3,4 +3,26 @@ def user_settings_tabs tabs = super tabs << { name: 'keys', partial: 'gitolite_public_keys/view', label: :label_public_keys } end + + # Hacked render_api_custom_values to add plugin values to user api. + # @NOTE: there is no solution for index.api, because @user is missing + # @TODO + def render_api_custom_values(custom_values, api) + rc = super + + if @user.present? + api.array :ssh_keys do + @user.gitolite_public_keys.each do |key| + api.ssh_key do + api.id key.id + api.key_type key.key_type_as_string + api.title key.title + api.key key.key + end + end + end + end + + rc + end end diff --git a/app/helpers/gitolite_plugin_settings_helper.rb b/app/helpers/gitolite_plugin_settings_helper.rb index 72d1b730bb0..461de80ded4 100644 --- a/app/helpers/gitolite_plugin_settings_helper.rb +++ b/app/helpers/gitolite_plugin_settings_helper.rb @@ -1,11 +1,11 @@ module GitolitePluginSettingsHelper def render_gitolite_params_status(params) - content_tag(:ul, class: 'list-unstyled') do + tag.ul class: 'list-unstyled' do content = '' params.each do |param, installed| - content << content_tag(:li, style: 'padding: 2px;') do + content << tag.li do image_tag(image_for_param(installed), style: 'vertical-align: bottom; padding-right: 5px;') + - content_tag(:em, label_for_param(param, installed)) + tag.em(label_for_param(param, installed)) end end content.html_safe @@ -29,35 +29,61 @@ def image_for_param(install_status) def render_gitolite_version(version) if version.nil? - css_class = 'label label-important' + css_class = 'label label-error' label = l(:label_unknown_gitolite_version) else css_class = 'label label-success' label = version end - content_tag(:span, label, class: css_class) + tag.span label, class: css_class end def render_temp_dir_writeable(state, label) - css_class = state ? 'label label-success' : 'label label-important' - content_tag(:span, label, class: css_class) + css_class = state ? 'label label-success' : 'label label-error' + tag.span label, class: css_class end def gitolite_plugin_settings_tabs [ - { name: 'gitolite_config_ssh', partial: 'settings/redmine_git_hosting/gitolite_config_ssh', label: :label_tab_ssh }, - { name: 'gitolite_config_storage', partial: 'settings/redmine_git_hosting/gitolite_config_storage', label: :label_tab_storage }, - { name: 'gitolite_config_file', partial: 'settings/redmine_git_hosting/gitolite_config_file', label: :label_tab_config_file }, - { name: 'gitolite_config_global', partial: 'settings/redmine_git_hosting/gitolite_config_global', label: :label_tab_global }, - { name: 'gitolite_config_access', partial: 'settings/redmine_git_hosting/gitolite_config_access', label: :label_tab_access }, - { name: 'gitolite_config_hooks', partial: 'settings/redmine_git_hosting/gitolite_config_hooks', label: :label_tab_hooks }, - { name: 'gitolite_config_cache', partial: 'settings/redmine_git_hosting/gitolite_config_cache', label: :label_tab_cache }, - { name: 'gitolite_config_notify', partial: 'settings/redmine_git_hosting/gitolite_config_notify', label: :label_tab_notify }, - { name: 'gitolite_redmine_config', partial: 'settings/redmine_git_hosting/redmine_config', label: :label_tab_redmine }, - { name: 'gitolite_sidekiq_interface', partial: 'settings/redmine_git_hosting/sidekiq_interface', label: :label_tab_sidekiq_interface }, - { name: 'gitolite_config_test', partial: 'settings/redmine_git_hosting/gitolite_config_test', label: :label_tab_config_test }, - { name: 'gitolite_recycle_bin', partial: 'settings/redmine_git_hosting/gitolite_recycle_bin', label: :label_tab_gitolite_recycle_bin }, - { name: 'gitolite_rescue', partial: 'settings/redmine_git_hosting/gitolite_rescue', label: :label_tab_gitolite_rescue } + { name: 'gitolite_config_ssh', + partial: 'settings/redmine_git_hosting/gitolite_config_ssh', + label: :label_tab_ssh }, + { name: 'gitolite_config_storage', + partial: 'settings/redmine_git_hosting/gitolite_config_storage', + label: :label_tab_storage }, + { name: 'gitolite_config_file', + partial: 'settings/redmine_git_hosting/gitolite_config_file', + label: :label_tab_config_file }, + { name: 'gitolite_config_global', + partial: 'settings/redmine_git_hosting/gitolite_config_global', + label: :label_tab_global }, + { name: 'gitolite_config_access', + partial: 'settings/redmine_git_hosting/gitolite_config_access', + label: :label_tab_access }, + { name: 'gitolite_config_hooks', + partial: 'settings/redmine_git_hosting/gitolite_config_hooks', + label: :label_tab_hooks }, + { name: 'gitolite_config_cache', + partial: 'settings/redmine_git_hosting/gitolite_config_cache', + label: :label_tab_cache }, + { name: 'gitolite_config_notify', + partial: 'settings/redmine_git_hosting/gitolite_config_notify', + label: :label_tab_notify }, + { name: 'gitolite_redmine_config', + partial: 'settings/redmine_git_hosting/redmine_config', + label: :label_tab_redmine }, + { name: 'gitolite_sidekiq_interface', + partial: 'settings/redmine_git_hosting/sidekiq_interface', + label: :label_tab_sidekiq_interface }, + { name: 'gitolite_config_test', + partial: 'settings/redmine_git_hosting/gitolite_config_test', + label: :label_tab_config_test }, + { name: 'gitolite_recycle_bin', + partial: 'settings/redmine_git_hosting/gitolite_recycle_bin', + label: :label_tab_gitolite_recycle_bin }, + { name: 'gitolite_rescue', + partial: 'settings/redmine_git_hosting/gitolite_rescue', + label: :label_tab_gitolite_rescue } ] end @@ -73,7 +99,7 @@ def git_cache_options end def log_level_options - RedmineGitHosting::Logger::LOG_LEVELS.map { |level| [l("label_#{level}"), level] } + RedmineGitHosting::FileLogger::LOG_LEVELS.map { |level| [l("label_#{level}"), level] } end def render_rugged_mandatory_features @@ -82,9 +108,9 @@ def render_rugged_mandatory_features opts = if RedmineGitHosting::Config.rugged_features.include?(feature) { class: 'label label-success' } else - { class: 'label label-important' } + { class: 'label label-error' } end - content << content_tag(:span, feature, opts) + "\n" + content << "#{tag.span feature, opts}\n" end content.html_safe end @@ -94,7 +120,7 @@ def render_rugged_optional_features RedmineGitHosting::Config.rugged_features.each do |feature| unless RedmineGitHosting::Config.rugged_mandatory_features.include?(feature) opts = { class: 'label label-success' } - content << content_tag(:span, feature, opts) + content << tag.span(feature, opts) end end content.html_safe diff --git a/app/helpers/gitolite_public_keys_helper.rb b/app/helpers/gitolite_public_keys_helper.rb index f6b2d9f3d5f..e38e483de08 100644 --- a/app/helpers/gitolite_public_keys_helper.rb +++ b/app/helpers/gitolite_public_keys_helper.rb @@ -1,16 +1,14 @@ module GitolitePublicKeysHelper - def keylabel(key) - key.user == User.current ? "#{key.title}" : "#{key.user.login}@#{key.title}" + key.user == User.current ? key.title&.to_s : "#{key.user.login}@#{key.title}" end - def can_create_deployment_keys_for_some_project(theuser = User.current) return true if theuser.admin? + theuser.projects_by_role.each_key do |role| return true if role.allowed_to?(:create_repository_deployment_credentials) end - return false + false end - end diff --git a/app/helpers/repository_deployment_credentials_helper.rb b/app/helpers/repository_deployment_credentials_helper.rb index a1f0d98f051..3a0262e6acc 100644 --- a/app/helpers/repository_deployment_credentials_helper.rb +++ b/app/helpers/repository_deployment_credentials_helper.rb @@ -1,19 +1,17 @@ module RepositoryDeploymentCredentialsHelper - def build_list_of_keys(user_keys, other_keys, disabled_keys) option_array = [[l(:label_deployment_credential_select_deploy_key), -1]] option_array += user_keys.map { |key| [keylabel(key), key.id] } - if !other_keys.empty? + if other_keys.present? option_array2 = other_keys.map { |key| [keylabel(key), key.id] } maxlen = (option_array + option_array2).map { |x| x.first.length }.max - extra = ([maxlen - l(:select_other_keys).length - 2, 6].max) / 2 + extra = [maxlen - l(:select_other_keys).length - 2, 6].max / 2 option_array += [[('-' * extra) + ' ' + l(:select_other_keys) + ' ' + ('-' * extra), -2]] option_array += option_array2 end options_for_select(option_array, selected: -1, disabled: [-2] + disabled_keys.map(&:id)) end - end diff --git a/app/helpers/repository_git_config_keys_helper.rb b/app/helpers/repository_git_config_keys_helper.rb index 18592423e67..54e059db236 100644 --- a/app/helpers/repository_git_config_keys_helper.rb +++ b/app/helpers/repository_git_config_keys_helper.rb @@ -1,10 +1,8 @@ module RepositoryGitConfigKeysHelper - def git_config_key_options [ [l(:label_git_key_type_config), 'RepositoryGitConfigKey::GitConfig'], [l(:label_git_key_type_option), 'RepositoryGitConfigKey::Option'] ] end - end diff --git a/app/helpers/repository_mirrors_helper.rb b/app/helpers/repository_mirrors_helper.rb index 832e9d86422..4a01be2b0c9 100644 --- a/app/helpers/repository_mirrors_helper.rb +++ b/app/helpers/repository_mirrors_helper.rb @@ -1,26 +1,26 @@ module RepositoryMirrorsHelper - # Mirror Mode def mirror_mode(mirror) - [l(:label_mirror_full_mirror), l(:label_mirror_forced_update), l(:label_mirror_fast_forward)][mirror.push_mode] + [l(:label_mirror_full_mirror), + l(:label_mirror_forced_update), + l(:label_mirror_fast_forward)][mirror.push_mode] end - # Refspec for mirrors def refspec(mirror, max_refspec = 0) if mirror.mirror_mode? - l(:all_references) + l :all_references else result = [] - result << l(:all_branches) if mirror.include_all_branches - result << l(:all_tags) if mirror.include_all_tags - result << mirror.explicit_refspec if (max_refspec == 0) || ((1..max_refspec) === mirror.explicit_refspec.length) - result << l(:explicit) if (max_refspec > 0) && (mirror.explicit_refspec.length > max_refspec) - result.join(',
') + result << tag.li(l(:all_branches)) if mirror.include_all_branches + result << tag.li(l(:all_tags)) if mirror.include_all_tags + result << tag.li(mirror.explicit_refspec) if max_refspec.zero? || ((1..max_refspec) === mirror.explicit_refspec.length) + result << tag.li(l(:explicit)) if max_refspec.positive? && (mirror.explicit_refspec.length > max_refspec) + + tag.ul(safe_join(result), class: 'list-unstyled') if result.any? end end - def mirrors_options [ [l(:label_mirror_full_mirror), 0], @@ -29,17 +29,15 @@ def mirrors_options ] end - def render_push_state(mirror, error) if error - status = l(:label_mirror_push_fail) - status_css = 'important' + status = l :label_mirror_push_fail + status_css = 'error' else - status = l(:label_mirror_push_sucess) + status = l :label_mirror_push_sucess status_css = 'success' end - l(:label_mirror_push_info_html, mirror_url: mirror.url, status: status, status_css: status_css).html_safe + t :label_mirror_push_info_html, mirror_url: mirror.url, status: status, status_css: status_css end - end diff --git a/app/helpers/repository_post_receive_urls_helper.rb b/app/helpers/repository_post_receive_urls_helper.rb index ecf7d9b63e2..c90f0f701d4 100644 --- a/app/helpers/repository_post_receive_urls_helper.rb +++ b/app/helpers/repository_post_receive_urls_helper.rb @@ -1,15 +1,13 @@ module RepositoryPostReceiveUrlsHelper - # Post-receive Mode def post_receive_mode(prurl) label = [] if prurl.github_mode? label << l(:label_github_post) - label << "(#{l(:label_split_payloads)})" if prurl.split_payloads? + label << "(#{l :label_split_payloads})" if prurl.split_payloads? else label << l(:label_empty_get) end - label.join(' ') + label.join ' ' end - end diff --git a/app/models/concerns/gitolitable/authorizations.rb b/app/models/concerns/gitolitable/authorizations.rb index dfa7e0ad0d0..fe2ef2bb198 100644 --- a/app/models/concerns/gitolitable/authorizations.rb +++ b/app/models/concerns/gitolitable/authorizations.rb @@ -8,82 +8,66 @@ def git_daemon_available? User.anonymous.allowed_to?(:view_changesets, project) && git_daemon_enabled? end - def git_web_available? User.anonymous.allowed_to?(:browse_repository, project) && smart_http_enabled? end - def protected_branches_available? protected_branches_enabled? && project.active? && protected_branches.any? end - def clonable_via_http? User.anonymous.allowed_to?(:view_changesets, project) || smart_http_enabled? end - def pushable_via_http? https_access_enabled? end - def git_notification_available? git_notification_enabled? && !mailing_list.empty? end - # These are for repository URLs def urls_are_viewable? - RedmineGitHosting::Config.show_repositories_url? && User.current.allowed_to?(:view_changesets, project) + User.current.allowed_to?(:view_changesets, project) end - def ssh_access_available? git_ssh_enabled? && !git_annex_enabled? && User.current.allowed_to_commit?(self) end - def https_access_available? https_access_enabled? end - def http_access_available? http_access_enabled? end - def git_access_available? (public_project? || public_repo?) && git_daemon_enabled? end - def go_access_available? (public_project? || public_repo?) && smart_http_enabled? && git_go_enabled? end - def git_annex_access_available? git_annex_enabled? end - def downloadable? git_annex_enabled? ? false : User.current.allowed_to_download?(self) end - def deletable? RedmineGitHosting::Config.delete_git_repositories? end - def movable? - !identifier.nil? && !identifier.empty? + identifier.present? end - end end diff --git a/app/models/concerns/gitolitable/cache.rb b/app/models/concerns/gitolitable/cache.rb index ba359d03610..b07320cffeb 100644 --- a/app/models/concerns/gitolitable/cache.rb +++ b/app/models/concerns/gitolitable/cache.rb @@ -4,14 +4,12 @@ module Cache included do class << self - # Are repositories identifier unique? # def repo_ident_unique? RedmineGitHosting::Config.unique_repo_identifier? end - # Translate repository path into a unique ID for use in caching of git commands. # def repo_path_to_git_cache_id(repo_path) @@ -19,7 +17,6 @@ def repo_path_to_git_cache_id(repo_path) repo ? repo.git_cache_id : nil end - # Parse a path of the form /// and return the specified # repository. If either 'repo_ident_unique?' is true or the is a project # identifier, just return the last component. Otherwise, @@ -60,11 +57,9 @@ def find_by_path(path, flags = {}) end end end - end end - # If repositories identifiers are unique, identifier forms a unique label, # else use directory notation: / # @@ -79,12 +74,10 @@ def git_cache_id end end - # Note: RedmineGitHosting::Cache doesn't know about repository object, it only knows *git_cache_id*. # def empty_cache! RedmineGitHosting::Cache.clear_cache_for_repository(git_cache_id) end - end end diff --git a/app/models/concerns/gitolitable/config.rb b/app/models/concerns/gitolitable/config.rb index 08d79c99e9d..43bec7474e7 100644 --- a/app/models/concerns/gitolitable/config.rb +++ b/app/models/concerns/gitolitable/config.rb @@ -37,7 +37,6 @@ def git_config repo_conf end - def gitolite_options repo_conf = {} @@ -48,31 +47,26 @@ def gitolite_options repo_conf end - def owner { name: Setting['app_title'], email: Setting['mail_from'] } end - def github_payload { - repository: { - owner: owner, - description: project.description, - fork: false, - forks: 0, - homepage: project.homepage, - name: redmine_name, - open_issues: project.issues.open.length, - watchers: 0, - private: !project.is_public, - url: repository_url - }, - pusher: owner, + repository: { owner: owner, + description: project.description, + fork: false, + forks: 0, + homepage: project.homepage, + name: redmine_name, + open_issues: project.issues.open.length, + watchers: 0, + private: !project.is_public, + url: repository_url }, + pusher: owner } end - def repository_url Rails.application.routes.url_helpers.url_for( controller: 'repositories', action: 'show', @@ -80,6 +74,5 @@ def repository_url only_path: false, host: Setting['host_name'], protocol: Setting['protocol'] ) end - end end diff --git a/app/models/concerns/gitolitable/features.rb b/app/models/concerns/gitolitable/features.rb index 84d8e9d9b04..79b5d9b75af 100644 --- a/app/models/concerns/gitolitable/features.rb +++ b/app/models/concerns/gitolitable/features.rb @@ -7,91 +7,73 @@ def report_last_commit true end - # Always true to force repository fetch_changesets. def extra_report_last_commit true end - def git_default_branch extra[:default_branch] end - def gitolite_hook_key extra[:key] end - def git_daemon_enabled? extra[:git_daemon] end - def git_annex_enabled? extra[:git_annex] end - def git_notification_enabled? extra[:git_notify] end - def git_ssh_enabled? extra[:git_ssh] end - def git_go_enabled? extra[:git_go] end - def https_access_enabled? extra[:git_https] end - def http_access_enabled? extra[:git_http] end - def smart_http_enabled? https_access_enabled? || http_access_enabled? end - def only_https_access_enabled? https_access_enabled? && !http_access_enabled? end - def only_http_access_enabled? http_access_enabled? && !https_access_enabled? end - def protected_branches_enabled? extra[:protected_branch] end - def public_project? project.is_public? end - def public_repo? extra[:public_repo] end - def urls_order extra[:urls_order] end - end end diff --git a/app/models/concerns/gitolitable/notifications.rb b/app/models/concerns/gitolitable/notifications.rb index 42d3a9ed0de..6d07c44a995 100644 --- a/app/models/concerns/gitolitable/notifications.rb +++ b/app/models/concerns/gitolitable/notifications.rb @@ -6,38 +6,24 @@ def mailing_list default_list + global_include_list - global_exclude_list end - def default_list watcher_users.map(&:email_address).map(&:address) end - def global_include_list RedmineGitHosting::Config.gitolite_notify_global_include end - def global_exclude_list RedmineGitHosting::Config.gitolite_notify_global_exclude end - def sender_address - if extra.notification_sender.nil? || extra.notification_sender.empty? - RedmineGitHosting::Config.gitolite_notify_global_sender_address - else - extra.notification_sender - end + extra.notification_sender.presence || RedmineGitHosting::Config.gitolite_notify_global_sender_address end - def email_prefix - if extra.notification_prefix.nil? || extra.notification_prefix.empty? - RedmineGitHosting::Config.gitolite_notify_global_prefix - else - extra.notification_prefix - end + extra.notification_prefix.presence || RedmineGitHosting::Config.gitolite_notify_global_prefix end - end end diff --git a/app/models/concerns/gitolitable/paths.rb b/app/models/concerns/gitolitable/paths.rb index adc3d68d712..df85dc2a0ab 100644 --- a/app/models/concerns/gitolitable/paths.rb +++ b/app/models/concerns/gitolitable/paths.rb @@ -2,7 +2,6 @@ module Gitolitable module Paths extend ActiveSupport::Concern - # This is the repository path from Redmine point of view. # It is used to build HTTP(s) urls (including GoLang url). # It doesn't contain references to internal directories like *gitolite_global_storage_dir* or *gitolite_redmine_storage_dir* @@ -14,10 +13,11 @@ module Paths # Call File.expand_path to add then remove heading / # def redmine_repository_path - File.expand_path(File.join('./', get_full_parent_path, git_cache_id), '/')[1..-1] + File.expand_path(File.join('./', + get_full_parent_path, + git_cache_id), '/')[1..-1] end - # This is the Gitolite repository identifier as it should appear in Gitolite config file. # Example : redmine/blabla/test-blabla/uuuuuuuuuuu/oooooo # (with 'redmine' a subdir of the Gitolite storage directory) @@ -25,10 +25,12 @@ def redmine_repository_path # Call File.expand_path to add then remove heading / # def gitolite_repository_name - File.expand_path(File.join('./', RedmineGitHosting::Config.gitolite_redmine_storage_dir, get_full_parent_path, git_cache_id), '/')[1..-1] + File.expand_path(File.join('./', + RedmineGitHosting::Config.gitolite_redmine_storage_dir, + get_full_parent_path, + git_cache_id), '/')[1..-1] end - # The Gitolite repository identifier with the .git extension. # Example : redmine/blabla/test-blabla/uuuuuuuuuuu/oooooo.git # @@ -36,7 +38,6 @@ def gitolite_repository_name_with_extension "#{gitolite_repository_name}.git" end - # This is the relative path to the Gitolite repository. # Example : repositories/redmine/blabla/test-blabla/uuuuuuuuuuu/oooooo.git # (with 'repositories' the Gitolite storage directory). @@ -45,7 +46,6 @@ def gitolite_repository_path File.join(RedmineGitHosting::Config.gitolite_global_storage_dir, gitolite_repository_name_with_extension) end - # This is the full absolute path to the Gitolite repository. # Example : /home/git/repositories/redmine/blabla/test-blabla/uuuuuuuuuuu/oooooo.git # @@ -53,7 +53,6 @@ def gitolite_full_repository_path File.join(RedmineGitHosting::Config.gitolite_home_dir, gitolite_repository_path) end - # A syntaxic sugar used to move repository from a location to an other # Example : repositories/blabla/test-blabla/uuuuuuuuuuu/oooooo # @@ -61,7 +60,6 @@ def new_repository_name gitolite_repository_name end - # Used to move repository from a location to an other. # At this point repository url still points to the old location but # it contains the Gitolite storage directory in its path and the '.git' extension. @@ -74,21 +72,19 @@ def old_repository_name url.gsub(RedmineGitHosting::Config.gitolite_global_storage_dir, '').gsub('.git', '') end - private + def get_full_parent_path + return '' unless RedmineGitHosting::Config.hierarchical_organisation? - def get_full_parent_path - return '' if !RedmineGitHosting::Config.hierarchical_organisation? - parent_parts = [] - p = project - while p.parent - parent_id = p.parent.identifier.to_s - parent_parts.unshift(parent_id) - p = p.parent - end - parent_parts.join('/') + parent_parts = [] + p = project + while p.parent + parent_id = p.parent.identifier.to_s + parent_parts.unshift(parent_id) + p = p.parent end - + parent_parts.join('/') + end end end diff --git a/app/models/concerns/gitolitable/permissions.rb b/app/models/concerns/gitolitable/permissions.rb index 70dffc45417..fcd89964655 100644 --- a/app/models/concerns/gitolitable/permissions.rb +++ b/app/models/concerns/gitolitable/permissions.rb @@ -6,7 +6,6 @@ def build_gitolite_permissions(old_perms = {}) permissions_builder.build(self, gitolite_users, old_perms) end - # We assume here that ':gitolite_config_file' is different than 'gitolite.conf' # like 'redmine.conf' with 'include "redmine.conf"' in 'gitolite.conf'. # This way, we know that all repos in this file are managed by Redmine so we @@ -20,47 +19,42 @@ def backup_gitolite_permissions(current_permissions) end end - private - - def permissions_builder - if protected_branches_available? - PermissionsBuilder::ProtectedBranches - else - PermissionsBuilder::Standard - end + def permissions_builder + if protected_branches_available? + PermissionsBuilder::ProtectedBranches + else + PermissionsBuilder::Standard end + end + SKIP_USERS = %w[gitweb daemon DUMMY_REDMINE_KEY REDMINE_ARCHIVED_PROJECT REDMINE_CLOSED_PROJECT].freeze - SKIP_USERS = ['gitweb', 'daemon', 'DUMMY_REDMINE_KEY', 'REDMINE_ARCHIVED_PROJECT', 'REDMINE_CLOSED_PROJECT'] - - - def extract_permissions(current_permissions) - old_permissions = {} - - current_permissions.each do |perm, branch_settings| - old_permissions[perm] = {} + def extract_permissions(current_permissions) + old_permissions = {} - branch_settings.each do |branch, user_list| - next if user_list.empty? + current_permissions.each do |perm, branch_settings| + old_permissions[perm] = {} - new_user_list = [] + branch_settings.each do |branch, user_list| + next if user_list.empty? - user_list.each do |user| - # ignore these users - next if SKIP_USERS.include?(user) + new_user_list = [] - # backup users that are not Redmine users - new_user_list.push(user) if !user.include?(RedmineGitHosting::Config.gitolite_identifier_prefix) - end + user_list.each do |user| + # ignore these users + next if SKIP_USERS.include?(user) - old_permissions[perm][branch] = new_user_list if new_user_list.any? + # backup users that are not Redmine users + new_user_list.push(user) unless user.include?(RedmineGitHosting::Config.gitolite_identifier_prefix) end - end - old_permissions + old_permissions[perm][branch] = new_user_list if new_user_list.any? + end end + old_permissions + end end end diff --git a/app/models/concerns/gitolitable/urls.rb b/app/models/concerns/gitolitable/urls.rb index bdcac73f86e..01daa319870 100644 --- a/app/models/concerns/gitolitable/urls.rb +++ b/app/models/concerns/gitolitable/urls.rb @@ -6,100 +6,87 @@ def http_user_login User.current.anonymous? ? '' : "#{User.current.login}@" end - def git_access_path gitolite_repository_name_with_extension end - def http_access_path "#{RedmineGitHosting::Config.http_server_subdir}#{redmine_repository_path}.git" end - def go_access_path "go/#{redmine_repository_path}" end - def ssh_url - if RedmineGitHosting::Config.gitolite_server_port == '22' - "ssh://#{RedmineGitHosting::Config.gitolite_user}@#{RedmineGitHosting::Config.ssh_server_domain}/#{git_access_path}" - else - "ssh://#{RedmineGitHosting::Config.gitolite_user}@#{RedmineGitHosting::Config.ssh_server_domain}:#{RedmineGitHosting::Config.gitolite_server_port}/#{git_access_path}" - end - end + url = "ssh://#{RedmineGitHosting::Config.gitolite_user}@#{RedmineGitHosting::Config.ssh_server_domain}" + url << if RedmineGitHosting::Config.gitolite_server_port == '22' + "/#{git_access_path}" + else + ":#{RedmineGitHosting::Config.gitolite_server_port}/#{git_access_path}" + end + + url + end def git_url "git://#{RedmineGitHosting::Config.ssh_server_domain}/#{git_access_path}" end - def http_url "http://#{http_user_login}#{RedmineGitHosting::Config.http_root_url}/#{http_access_path}" end - def https_url "https://#{http_user_login}#{RedmineGitHosting::Config.https_root_url}/#{http_access_path}" end - def git_annex_url "#{RedmineGitHosting::Config.gitolite_user}@#{RedmineGitHosting::Config.ssh_server_domain}:#{git_access_path}" end - # This is the url used by Go to clone repository # def go_access_url - return '' if !smart_http_enabled? + return '' unless smart_http_enabled? return https_url if https_access_available? return http_url if http_access_available? end - # This is the url to add in Go files # def go_url - return '' if !smart_http_enabled? + return '' unless smart_http_enabled? return "#{RedmineGitHosting::Config.https_root_url}/#{go_access_path}" if https_access_available? return "#{RedmineGitHosting::Config.http_root_url}/#{go_access_path}" if http_access_available? end - def ssh_access { url: ssh_url, committer: User.current.allowed_to_commit?(self).to_s } end - ## Unsecure channels (clear password), commit is disabled def http_access { url: http_url, committer: 'false' } end - def https_access { url: https_url, committer: User.current.allowed_to_commit?(self).to_s } end - def git_access { url: git_url, committer: 'false' } end - def git_annex_access { url: git_annex_url, committer: User.current.allowed_to_commit?(self).to_s } end - def go_access { url: go_url, committer: 'false' } end - def available_urls hash = {} hash[:ssh] = ssh_access if ssh_access_available? @@ -111,16 +98,17 @@ def available_urls hash end - def available_urls_sorted - return available_urls if urls_order.nil? || urls_order.empty? + return available_urls if urls_order.blank? + hash = {} urls_order.each do |url| - next if !available_urls[url.to_sym] - hash[url.to_sym] = available_urls[url.to_sym] + available_url = available_urls[url.to_sym] + next if available_url.blank? + + hash[url.to_sym] = available_url end hash end - end end diff --git a/app/models/concerns/gitolitable/users.rb b/app/models/concerns/gitolitable/users.rb index 3aa3f5ad8b6..00efdc9a5ba 100644 --- a/app/models/concerns/gitolitable/users.rb +++ b/app/models/concerns/gitolitable/users.rb @@ -12,7 +12,6 @@ def gitolite_users end end - def users_for_active_project data = {} data[:rewind_users] = rewind_users + rewind_deploy_users @@ -30,14 +29,12 @@ def users_for_active_project data end - def users_for_archived_project data = {} data[:read_users] = ['REDMINE_ARCHIVED_PROJECT'] data end - def users_for_closed_project data = {} data[:read_users] = all_users @@ -45,65 +42,54 @@ def users_for_closed_project data end - def users project.users_available end - def rewind_users @rewind_users ||= users.select { |u| u.allowed_to?(:manage_repository, project) }.map { |u| u.gitolite_identifier }.sort end - def write_users @write_users ||= users.select { |u| u.allowed_to?(:commit_access, project) }.map { |u| u.gitolite_identifier }.sort - rewind_users end - def read_users - @read_users ||= users.select { |u| u.allowed_to?(:view_changesets, project) }.map { |u| u.gitolite_identifier }.sort - rewind_users - write_users + @read_users ||= users.select { |u| u.allowed_to?(:view_changesets, project) } + .map { |u| u.gitolite_identifier } + .sort - rewind_users - write_users end - def developer_team @developer_team ||= (rewind_users + write_users).sort end - def all_users @all_users ||= (rewind_users + write_users + read_users).sort end - def rewind_deploy_users - deploy_users_for_keys(rewind_deploy_keys) + deploy_users_for_keys rewind_deploy_keys end - def read_deploy_users - deploy_users_for_keys(read_deploy_keys) + deploy_users_for_keys read_deploy_keys end - def rewind_deploy_keys - deploy_keys_by_perm('RW+') + deploy_keys_by_perm 'RW+' end - def read_deploy_keys - deploy_keys_by_perm('R') + deploy_keys_by_perm 'R' end - def deploy_keys_by_perm(perm) deployment_credentials.active.select { |cred| cred.perm == perm } end - def deploy_users_for_keys(keys) keys.map { |cred| cred.gitolite_public_key.owner } end - end end diff --git a/app/models/concerns/gitolitable/validations.rb b/app/models/concerns/gitolitable/validations.rb index d330d57830c..cd547808c86 100644 --- a/app/models/concerns/gitolitable/validations.rb +++ b/app/models/concerns/gitolitable/validations.rb @@ -9,7 +9,7 @@ module Validations # Make sure that identifier does not match Gitolite Admin repository # - validates_exclusion_of :identifier, in: %w(gitolite-admin) + validates_exclusion_of :identifier, in: %w[gitolite-admin] # Place additional constraints on repository identifiers # because of multi repos @@ -19,7 +19,6 @@ module Validations validate :default_repository_has_identifier class << self - # Build a hash of repository identifier : # => 1 # => 1 @@ -28,41 +27,34 @@ class << self # Repository identifiers are unique if all values of the hash are 1. # def identifiers_to_hash - self.all.map(&:identifier).inject(Hash.new(0)) do |h, x| - h[x] += 1 unless x.blank? + all.map(&:identifier).inject(Hash.new(0)) do |h, x| + h[x] += 1 if x.present? h end end - def have_duplicated_identifier? (identifiers_to_hash.values.max || 0) > 1 end - end end - def exists_in_gitolite? RedmineGitHosting::Commands.sudo_dir_exists?(gitolite_repository_path) end - def empty_in_gitolite? RedmineGitHosting::Commands.sudo_repository_empty?(gitolite_repository_path) end - def git_objects_count RedmineGitHosting::Commands.sudo_git_objects_count(File.join(gitolite_repository_path, 'objects')) end - def empty? - extra_info.nil? || (!extra_info.has_key?('heads') && !extra_info.has_key?('branches')) + extra_info.nil? || (!extra_info.key?('heads') && !extra_info.key?('branches')) end - def data_for_destruction { repo_name: gitolite_repository_name, @@ -72,51 +64,50 @@ def data_for_destruction } end - private + # Set up git urls for new repositories + # + def set_git_urls + self.url = gitolite_repository_path if url.blank? + self.root_url = url if root_url.blank? + end - # Set up git urls for new repositories - # - def set_git_urls - self.url = gitolite_repository_path if self.url.blank? - self.root_url = self.url if self.root_url.blank? - end - - - # Check several aspects of repository identifier (only for Redmine 1.4+) - # 1) cannot equal identifier of any project - # 2) if repo_ident_unique? make sure that repo identifier is globally unique - # 3) cannot make this repo the default if there will be some other repo with blank identifier - # - def additional_constraints_on_identifier - if !identifier.blank? && (new_record? || identifier_changed?) - errors.add(:identifier, :cannot_equal_project) if Project.find_by_identifier(identifier) - - # See if a repo for another project has the same identifier (existing validations already check for current project) - errors.add(:identifier, :taken) if self.class.repo_ident_unique? && Repository.where("identifier = ? and project_id <> ?", identifier, project.id).any? + # Check several aspects of repository identifier (only for Redmine 1.4+) + # 1) cannot equal identifier of any project + # 2) if repo_ident_unique? make sure that repo identifier is globally unique + # 3) cannot make this repo the default if there will be some other repo with blank identifier + # + def additional_constraints_on_identifier + if identifier.present? && (new_record? || identifier_changed?) + errors.add(:identifier, :cannot_equal_project) if Project.find_by_identifier(identifier) + + # See if a repo for another project has the same identifier (existing validations already check for current project) + if self.class.repo_ident_unique? && Repository.where("identifier = ? and project_id <> ?", identifier, project.id).any? + errors.add :identifier, :taken end end + end + # Make sure identifier hasn't changed. Allow null and blank + # Note that simply using identifier_changed doesn't seem to work + # if the identifier was "NULL" but the new identifier is "" + # + def identifier_dont_change + return if new_record? - # Make sure identifier hasn't changed. Allow null and blank - # Note that simply using identifier_changed doesn't seem to work - # if the identifier was "NULL" but the new identifier is "" - # - def identifier_dont_change - return if new_record? - errors.add(:identifier, :cannot_change) if (identifier_was.blank? && !identifier.blank?) || (!identifier_was.blank? && identifier_changed?) + if (identifier_was.blank? && identifier.present?) || (identifier_was.present? && identifier_changed?) + errors.add :identifier, :cannot_change end + end - - # Need to make sure that we don't take the default slot away from a sibling repo with blank identifier - # - def default_repository_has_identifier - if project && (is_default? || set_as_default?) - possibles = Repository.where("project_id = ? and (identifier = '' or identifier is null)", project.id) - errors.add(:base, :blank_default_exists) if possibles.any? && (new_record? || possibles.detect { |x| x.id != id }) - end + # Need to make sure that we don't take the default slot away from a sibling repo with blank identifier + # + def default_repository_has_identifier + if project && (is_default? || set_as_default?) + possibles = Repository.where("project_id = ? and (identifier = '' or identifier is null)", project.id) + errors.add(:base, :blank_default_exists) if possibles.any? && (new_record? || possibles.detect { |x| x.id != id }) end - + end end end diff --git a/app/models/github_comment.rb b/app/models/github_comment.rb index c4f6c0f6144..8453f88723f 100644 --- a/app/models/github_comment.rb +++ b/app/models/github_comment.rb @@ -1,5 +1,4 @@ class GithubComment < ActiveRecord::Base - ## Relations belongs_to :journal diff --git a/app/models/github_issue.rb b/app/models/github_issue.rb index 32919373234..a3b0482a2cf 100644 --- a/app/models/github_issue.rb +++ b/app/models/github_issue.rb @@ -1,5 +1,4 @@ class GithubIssue < ActiveRecord::Base - ## Relations belongs_to :issue diff --git a/app/models/gitolite_public_key.rb b/app/models/gitolite_public_key.rb index ea9b80c6f9b..14a3763d9e6 100644 --- a/app/models/gitolite_public_key.rb +++ b/app/models/gitolite_public_key.rb @@ -32,6 +32,7 @@ class GitolitePublicKey < ActiveRecord::Base ## Scopes scope :user_key, -> { where(key_type: KEY_TYPE_USER) } scope :deploy_key, -> { where(key_type: KEY_TYPE_DEPLOY) } + scope :sorted, -> { order(:title, :created_at) } ## Callbacks before_validation :strip_whitespace diff --git a/app/models/protected_branches_member.rb b/app/models/protected_branches_member.rb index ebc69043ed3..02d8d8ed1c8 100644 --- a/app/models/protected_branches_member.rb +++ b/app/models/protected_branches_member.rb @@ -18,7 +18,7 @@ def remove_dependent_objects principal.users.each do |user| member = self.class.find_by_principal_id_and_inherited_by(user.id, principal.id) - member.destroy! unless member.nil? + member&.destroy! end end end diff --git a/app/models/repository_deployment_credential.rb b/app/models/repository_deployment_credential.rb index 22380663622..fe4bee0a7f3 100644 --- a/app/models/repository_deployment_credential.rb +++ b/app/models/repository_deployment_credential.rb @@ -16,7 +16,7 @@ class RepositoryDeploymentCredential < ActiveRecord::Base validates :repository_id, presence: true, uniqueness: { scope: :gitolite_public_key_id } - validates :gitolite_public_key_id, presence: true + validates :gitolite_public_key_id, presence: true, exclusion: { in: [-1] } validates :user_id, presence: true validates :perm, presence: true, inclusion: { in: VALID_PERMS } @@ -29,8 +29,9 @@ class RepositoryDeploymentCredential < ActiveRecord::Base validate :owner_matches_key ## Scopes - scope :active, -> { where(active: true) } + scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } + scope :sorted, -> { order(:id) } def to_s "#{repository.identifier}-#{gitolite_public_key.identifier} : #{perm}" diff --git a/app/models/repository_git_config_key/git_config.rb b/app/models/repository_git_config_key/git_config.rb index f3f6c3978dc..e75ad9d44d0 100644 --- a/app/models/repository_git_config_key/git_config.rb +++ b/app/models/repository_git_config_key/git_config.rb @@ -1,9 +1,7 @@ class RepositoryGitConfigKey::GitConfig < RepositoryGitConfigKey - VALID_CONFIG_KEY_REGEX = /\A[a-zA-Z0-9]+\.[a-zA-Z0-9.]+\z/ validates :key, presence: true, - uniqueness: { case_sensitive: false, scope: [:type, :repository_id] }, - format: { with: VALID_CONFIG_KEY_REGEX } - + uniqueness: { case_sensitive: false, scope: %i[type repository_id] }, + format: { with: VALID_CONFIG_KEY_REGEX } end diff --git a/app/models/repository_git_config_key/option.rb b/app/models/repository_git_config_key/option.rb index ddd3e488707..bfb1c402c76 100644 --- a/app/models/repository_git_config_key/option.rb +++ b/app/models/repository_git_config_key/option.rb @@ -1,6 +1,4 @@ class RepositoryGitConfigKey::Option < RepositoryGitConfigKey - validates :key, presence: true, - uniqueness: { case_sensitive: false, scope: [:type, :repository_id] } - + uniqueness: { case_sensitive: false, scope: %i[type repository_id] } end diff --git a/app/models/repository_mirror.rb b/app/models/repository_mirror.rb index af6a8fbd220..5236ad01534 100644 --- a/app/models/repository_mirror.rb +++ b/app/models/repository_mirror.rb @@ -30,9 +30,10 @@ class RepositoryMirror < ActiveRecord::Base validate :mirror_configuration ## Scopes - scope :active, -> { where(active: true) } - scope :inactive, -> { where(active: false) } + scope :active, -> { where(active: true) } + scope :inactive, -> { where(active: false) } scope :has_explicit_refspec, -> { where(push_mode: '> 0') } + scope :sorted, -> { order(:url) } ## Callbacks before_validation :strip_whitespace diff --git a/app/models/repository_post_receive_url.rb b/app/models/repository_post_receive_url.rb index 00ef49f3336..04384be7628 100644 --- a/app/models/repository_post_receive_url.rb +++ b/app/models/repository_post_receive_url.rb @@ -15,16 +15,17 @@ class RepositoryPostReceiveUrl < ActiveRecord::Base # Only allow HTTP(s) format validates :url, presence: true, uniqueness: { case_sensitive: false, scope: :repository_id }, - format: { with: URI::regexp(%w[http https]) } + format: { with: URI::DEFAULT_PARSER.make_regexp(%w[http https]) } - validates :mode, presence: true, inclusion: { in: %i[github get] } + validates :mode, presence: true, inclusion: { in: %i[github get post] } ## Serializations serialize :triggers, Array ## Scopes - scope :active, -> { where(active: true) } + scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } + scope :sorted, -> { order(:url) } ## Callbacks before_validation :strip_whitespace @@ -46,7 +47,11 @@ def github_mode? # Strip leading and trailing whitespace def strip_whitespace - self.url = url.strip rescue '' + self.url = begin + url.strip + rescue StandardError + '' + end end # Remove blank entries in triggers diff --git a/app/models/repository_protected_branche.rb b/app/models/repository_protected_branche.rb index 95847514d30..19db96158c3 100644 --- a/app/models/repository_protected_branche.rb +++ b/app/models/repository_protected_branche.rb @@ -20,6 +20,7 @@ class RepositoryProtectedBranche < ActiveRecord::Base ## Scopes default_scope { order(position: :asc) } + scope :sorted, -> { order(:path) } class << self def clone_from(parent) diff --git a/app/presenters/repository_presenter.rb b/app/presenters/repository_presenter.rb index 259d1de027b..b8a6e91889b 100644 --- a/app/presenters/repository_presenter.rb +++ b/app/presenters/repository_presenter.rb @@ -17,7 +17,7 @@ def link_to_repository end def git_urls_box - content_tag(:div, class: 'git_url_box', id: urls_container_id) do + tag.div(class: 'git_url_box', id: urls_container_id) do render_git_urls + render_git_url_text + render_permissions + @@ -28,31 +28,31 @@ def git_urls_box private def render_git_urls - content_tag(:ul, render_url_list, class: 'git_url_list') + tag.ul(render_url_list, class: 'git_url_list') end def render_url_list s = '' repository.available_urls_sorted.each do |key, value| - s << content_tag(:li, link_to(key.upcase, 'javascript:void(0)').html_safe, options_for_git_url(key, value)) + s << tag.li(link_to(key.upcase, 'javascript:void(0)').html_safe, options_for_git_url(key, value)) end s.html_safe end - def options_for_git_url(key, value) + def options_for_git_url(_key, value) { class: 'git_url', data: { url: value[:url], target: element_name, committer: committer_label(value) } } end def render_git_url_text - content_tag(:input, '', class: 'git_url_text', id: url_text_container_id, readonly: 'readonly') + tag.input '', class: 'git_url_text', id: url_text_container_id, readonly: 'readonly' end def render_permissions - content_tag(:div, content_tag(:span, '', id: permissions_container_id), class: 'git_url_permissions') + tag.div tag.span('', id: permissions_container_id), class: 'git_url_permissions' end def render_clipboard_button - clipboardjs_button_for(url_text_container_id) + clipboardjs_button_for url_text_container_id end def committer_label(value) diff --git a/app/reports/report_base.rb b/app/reports/report_base.rb index 2e10eed7f2d..41c0ef1fd03 100644 --- a/app/reports/report_base.rb +++ b/app/reports/report_base.rb @@ -1,5 +1,4 @@ class ReportBase - include Redmine::I18n include ReportHelper include ReportQuery @@ -9,5 +8,4 @@ class ReportBase def initialize(repository) @repository = repository end - end diff --git a/app/reports/repository_contributors_stats.rb b/app/reports/repository_contributors_stats.rb index bce8700da7a..e92613b96c7 100644 --- a/app/reports/repository_contributors_stats.rb +++ b/app/reports/repository_contributors_stats.rb @@ -1,11 +1,9 @@ class RepositoryContributorsStats < ReportBase - def initialize(repository) super @changes_for_committer = {} end - def commits_per_author data = [] @@ -30,7 +28,6 @@ def commits_per_author data end - def commits_per_author_global merged = commits_per_author_with_aliases data = {} @@ -41,67 +38,68 @@ def commits_per_author_global data end - private + # Generate mappings from the registered users to the comitters + # user_committer_mapping = { name => [comitter, ...] } + # registered_committers = [ committer,... ] + # + def commits_per_author_with_aliases + return @commits_per_author_with_aliases if !@commits_per_author_with_aliases.nil? + + @commits_per_author_with_aliases = nil + + registered_committers = [] + user_committer_mapping = {} + Changeset.select('changesets.committer, changesets.user_id') + .where(repository_id: repository.id) + .where.not(user_id: nil) + .group(:committer, :user_id) + .includes(:user).each do |x| + name = "#{x.user.firstname} #{x.user.lastname}" + registered_committers << x.committer + user_committer_mapping[[name, x.user.mail]] ||= [] + user_committer_mapping[[name, x.user.mail]] << x.committer + end - # Generate mappings from the registered users to the comitters - # user_committer_mapping = { name => [comitter, ...] } - # registered_committers = [ committer,... ] - # - def commits_per_author_with_aliases - return @commits_per_author_with_aliases if !@commits_per_author_with_aliases.nil? - @commits_per_author_with_aliases = nil - - registered_committers = [] - user_committer_mapping = {} - Changeset.select('changesets.committer, changesets.user_id') - .where('repository_id = ? and user_id IS NOT NULL', repository.id) - .group(:committer, :user_id) - .includes(:user).each do |x| - name = "#{x.user.firstname} #{x.user.lastname}" - registered_committers << x.committer - user_committer_mapping[[name, x.user.mail]] ||= [] - user_committer_mapping[[name, x.user.mail]] << x.committer - end - - merged = [] - commits_by_author.each do |committer, count| - # skip all registered users - next if registered_committers.include?(committer) + merged = [] + commits_by_author.each do |committer, count| + # skip all registered users + next if registered_committers.include?(committer) - name = committer.gsub(%r{<.+@.+>}, '').strip - mail = committer[/<(.+@.+)>/, 1] - merged << { name: name, mail: mail, commits: count, changes: changes_by_author[committer] || 0, committers: [committer] } - end - user_committer_mapping.each do |identity, committers| - count = 0 - changes = 0 - committers.each do |c| - count += commits_by_author[c] || 0 - changes += changes_by_author[c] || 0 - end - merged << { name: identity[0], mail: identity[1], commits: count, changes: changes, committers: committers } + name = committer.gsub(%r{<.+@.+>}, '').strip + mail = committer[/<(.+@.+)>/, 1] + merged << { name: name, mail: mail, commits: count, changes: changes_by_author[committer] || 0, committers: [committer] } + end + user_committer_mapping.each do |identity, committers| + count = 0 + changes = 0 + committers.each do |c| + count += commits_by_author[c] || 0 + changes += changes_by_author[c] || 0 end - - # sort by name - merged.sort! { |x, y| x[:name] <=> y[:name] } - - # merged = merged + [{name:"",commits:0,changes:0}]*(10 - merged.length) if merged.length < 10 - @commits_per_author_with_aliases = merged - @commits_per_author_with_aliases + merged << { name: identity[0], mail: identity[1], commits: count, changes: changes, committers: committers } end + # sort by name + merged.sort! { |x, y| x[:name] <=> y[:name] } - def sorted_commits_per_author_with_aliases - @committers ||= commits_per_author_with_aliases.sort! { |x, y| y[:commits] <=> x[:commits] } - end + # merged = merged + [{name:"",commits:0,changes:0}]*(10 - merged.length) if merged.length < 10 + @commits_per_author_with_aliases = merged + @commits_per_author_with_aliases + end + def sorted_commits_per_author_with_aliases + @committers ||= commits_per_author_with_aliases.sort! { |x, y| y[:commits] <=> x[:commits] } + end - def count_changes_for_committer(committer) - return @changes_for_committer[committer] if !@changes_for_committer[committer].nil? - @changes_for_committer[committer] ||= Changeset.where('repository_id = ? AND committer = ?', repository.id, committer).group(:commit_date).order(:commit_date).count - @changes_for_committer[committer] - end + def count_changes_for_committer(committer) + return @changes_for_committer[committer] unless @changes_for_committer[committer].nil? + @changes_for_committer[committer] ||= Changeset.where(repository_id: repository.id, committer: committer) + .group(:commit_date) + .order(:commit_date) + .count + @changes_for_committer[committer] + end end diff --git a/app/services/permissions_builder/base.rb b/app/services/permissions_builder/base.rb index be9ce3865d0..37b9830b859 100644 --- a/app/services/permissions_builder/base.rb +++ b/app/services/permissions_builder/base.rb @@ -1,10 +1,6 @@ module PermissionsBuilder class Base - - attr_reader :repository - attr_reader :gitolite_users - attr_reader :old_permissions - + attr_reader :repository, :gitolite_users, :old_permissions def initialize(repository, gitolite_users, old_permissions = {}) @repository = repository @@ -12,27 +8,20 @@ def initialize(repository, gitolite_users, old_permissions = {}) @old_permissions = old_permissions end - class << self - def build(repository, gitolite_users, old_permissions = {}) new(repository, gitolite_users, old_permissions).build end - end - def build raise NotImplementedError end - private - - def has_no_users?(type) - gitolite_users[type].nil? || gitolite_users[type].empty? - end - + def no_users?(type) + gitolite_users[type].blank? + end end end diff --git a/app/services/permissions_builder/protected_branches.rb b/app/services/permissions_builder/protected_branches.rb index 45adb1a57b3..ff323c3e326 100644 --- a/app/services/permissions_builder/protected_branches.rb +++ b/app/services/permissions_builder/protected_branches.rb @@ -1,21 +1,17 @@ module PermissionsBuilder class ProtectedBranches < Base - attr_reader :permissions - def initialize(*args) super @permissions = [] end - def build build_protected_branch_permissions permissions end - def build_protected_branch_permissions repository.protected_branches.each do |branch| perms = {} @@ -24,6 +20,5 @@ def build_protected_branch_permissions permissions.push(perms) end end - end end diff --git a/app/services/permissions_builder/standard.rb b/app/services/permissions_builder/standard.rb index a32de27e2f7..1f5daae4fc0 100644 --- a/app/services/permissions_builder/standard.rb +++ b/app/services/permissions_builder/standard.rb @@ -1,9 +1,7 @@ module PermissionsBuilder class Standard < Base - attr_reader :permissions - def initialize(*args) super @permissions = {} @@ -12,7 +10,6 @@ def initialize(*args) @permissions['R'] = {} end - def build # Build permissions build_permissions @@ -21,51 +18,43 @@ def build [merge_permissions(permissions, old_permissions)] end - private + def build_permissions + @permissions['RW+'][''] = gitolite_users[:rewind_users] unless no_users?(:rewind_users) + @permissions['RW'][''] = gitolite_users[:write_users] unless no_users?(:write_users) + @permissions['R'][''] = gitolite_users[:read_users] unless no_users?(:read_users) + end - def build_permissions - @permissions['RW+'][''] = gitolite_users[:rewind_users] unless has_no_users?(:rewind_users) - @permissions['RW'][''] = gitolite_users[:write_users] unless has_no_users?(:write_users) - @permissions['R'][''] = gitolite_users[:read_users] unless has_no_users?(:read_users) - end - + def merge_permissions(current_permissions, old_permissions) + merge_permissions = {} + merge_permissions['RW+'] = {} + merge_permissions['RW'] = {} + merge_permissions['R'] = {} - def merge_permissions(current_permissions, old_permissions) - merge_permissions = {} - merge_permissions['RW+'] = {} - merge_permissions['RW'] = {} - merge_permissions['R'] = {} + current_permissions.each do |perm, branch_settings| + branch_settings.each do |branch, user_list| + next unless user_list.any? - current_permissions.each do |perm, branch_settings| - branch_settings.each do |branch, user_list| - if user_list.any? - if !merge_permissions[perm].has_key?(branch) - merge_permissions[perm][branch] = [] - end - merge_permissions[perm][branch] += user_list - end - end + merge_permissions[perm][branch] = [] unless merge_permissions[perm].key?(branch) + merge_permissions[perm][branch] += user_list end + end - old_permissions.each do |perm, branch_settings| - branch_settings.each do |branch, user_list| - if user_list.any? - if !merge_permissions[perm].has_key?(branch) - merge_permissions[perm][branch] = [] - end - merge_permissions[perm][branch] += user_list - end - end - end + old_permissions.each do |perm, branch_settings| + branch_settings.each do |branch, user_list| + next unless user_list.any? - merge_permissions.each do |perm, branch_settings| - merge_permissions.delete(perm) if merge_permissions[perm].empty? + merge_permissions[perm][branch] = [] unless merge_permissions[perm].key?(branch) + merge_permissions[perm][branch] += user_list end + end - merge_permissions + merge_permissions.each do |perm, _branch_settings| + merge_permissions.delete(perm) if merge_permissions[perm].empty? end + merge_permissions + end end end diff --git a/app/services/redmine_hooks/base.rb b/app/services/redmine_hooks/base.rb index 655a3274e6c..b9ad486f977 100644 --- a/app/services/redmine_hooks/base.rb +++ b/app/services/redmine_hooks/base.rb @@ -1,70 +1,54 @@ module RedmineHooks class Base - - attr_reader :object - attr_reader :payloads - + attr_reader :object, :payloads def initialize(object, payloads = {}) @object = object @payloads = payloads end - class << self - def call(object, payloads = {}) new(object, payloads).call end - end - def call raise NotImplementedError end - def start_message raise NotImplementedError end - private + def logger + RedmineGitHosting.logger + end - def logger - RedmineGitHosting.logger - end - - - def success_message - " [success]\n" - end - - - def failure_message - " [failure]\n" - end - - - def log_hook_succeeded - logger.info('Succeeded!') - end - + def success_message + " [success]\n" + end - def log_hook_failed - logger.error('Failed!') - end + def failure_message + " [failure]\n" + end + def log_hook_succeeded + logger.info 'Succeeded!' + end - def execute_hook(&block) - y = '' - logger.info(start_message) - y << " - #{start_message} ... " - yield y - y - end + def log_hook_failed + logger.error 'Failed!' + end + def execute_hook(&block) + y = '' + logger.info start_message + y << " - #{start_message} ... " + yield y + y + end end end diff --git a/app/services/redmine_hooks/call_webservices.rb b/app/services/redmine_hooks/call_webservices.rb index e7384b7dbea..cba08800f9e 100644 --- a/app/services/redmine_hooks/call_webservices.rb +++ b/app/services/redmine_hooks/call_webservices.rb @@ -1,11 +1,9 @@ module RedmineHooks class CallWebservices < Base - include HttpHelper attr_reader :payloads_to_send - def initialize(*args) super @@ -13,106 +11,101 @@ def initialize(*args) set_payloads_to_send end - def call execute_hook do |out| if needs_push? out << call_webservice else out << "#{skip_message}\n" - logger.info(skip_message) + logger.info skip_message end end end - def post_receive_url object end - def needs_push? + return true if post_receive_url.mode == :post return false if payloads.empty? return true unless use_triggers? return false if post_receive_url.triggers.empty? - return !payloads_to_send.empty? - end + !payloads_to_send.empty? + end def start_message - "Notifying #{post_receive_url.url}" + uri = URI post_receive_url.url + if uri.password.present? + uri.user = nil + uri.password = nil + "Notifying #{uri} (with base auth)" + else + "Notifying #{post_receive_url.url}" + end end - def skip_message "This url doesn't need to be notified" end - private + def set_payloads_to_send + @payloads_to_send = if post_receive_url.mode == :post + {} + elsif use_triggers? + extract_payloads + else + payloads + end + end - def set_payloads_to_send - if use_triggers? - @payloads_to_send = extract_payloads - else - @payloads_to_send = payloads - end - end - - - def extract_payloads - new_payloads = [] - payloads.each do |payload| - data = RedmineGitHosting::Utils::Git.parse_refspec(payload[:ref]) - if data[:type] == 'heads' && post_receive_url.triggers.include?(data[:name]) - new_payloads << payload - end - end - new_payloads - end - - - def use_method - post_receive_url.mode == :github ? :http_post : :http_get - end - - - def use_triggers? - post_receive_url.use_triggers? + def extract_payloads + new_payloads = [] + payloads.each do |payload| + data = RedmineGitHosting::Utils::Git.parse_refspec(payload[:ref]) + new_payloads << payload if data[:type] == 'heads' && post_receive_url.triggers.include?(data[:name]) end + new_payloads + end + def use_method + post_receive_url.mode == :get ? :http_get : :http_post + end - def split_payloads? - post_receive_url.split_payloads? - end + def use_triggers? + post_receive_url.use_triggers? + end + def split_payloads? + post_receive_url.split_payloads? + end - def call_webservice - if use_method == :http_post && split_payloads? - y = '' - payloads_to_send.each do |payload| - y << do_call_webservice(payload) - end - y - else - do_call_webservice(payloads_to_send) + def call_webservice + if use_method == :http_post && split_payloads? + y = '' + payloads_to_send.each do |payload| + y << do_call_webservice(payload) end + y + else + do_call_webservice payloads_to_send end + end + def do_call_webservice(payload) + post_failed, post_message = send(use_method, post_receive_url.url, { data: { payload: payload } }) - def do_call_webservice(payload) - post_failed, post_message = self.send(use_method, post_receive_url.url, { data: { payload: payload } }) - - if post_failed - logger.error('Failed!') - logger.error(post_message) - (split_payloads? ? failure_message.gsub("\n", '') : failure_message) - else - log_hook_succeeded - (split_payloads? ? success_message.gsub("\n", '') : success_message) - end + if post_failed + logger.error 'Failed!' + logger.error post_message + (split_payloads? ? failure_message.delete("\n") : failure_message) + else + log_hook_succeeded + (split_payloads? ? success_message.delete("\n") : success_message) end - + end end end diff --git a/app/services/redmine_hooks/fetch_changesets.rb b/app/services/redmine_hooks/fetch_changesets.rb index f67ce71910f..ca9454ef5de 100644 --- a/app/services/redmine_hooks/fetch_changesets.rb +++ b/app/services/redmine_hooks/fetch_changesets.rb @@ -1,6 +1,5 @@ module RedmineHooks class FetchChangesets < Base - def call repository.empty_cache! execute_hook do |out| @@ -8,31 +7,24 @@ def call end end - def repository object end - def start_message "Fetching changesets for '#{repository.redmine_name}' repository" end - private - - def fetch_changesets - begin - repository.fetch_changesets - log_hook_succeeded - success_message - rescue ::Redmine::Scm::Adapters::CommandFailed => e - log_hook_failed - logger.error("Error during fetching changesets : #{e.message}") - failure_message - end - end - + def fetch_changesets + repository.fetch_changesets + log_hook_succeeded + success_message + rescue ::Redmine::Scm::Adapters::CommandFailed => e + log_hook_failed + logger.error "Error during fetching changesets : #{e.message}" + failure_message + end end end diff --git a/app/services/redmine_hooks/github_issues_sync.rb b/app/services/redmine_hooks/github_issues_sync.rb index 36d487d06f3..38d63de243a 100644 --- a/app/services/redmine_hooks/github_issues_sync.rb +++ b/app/services/redmine_hooks/github_issues_sync.rb @@ -2,151 +2,137 @@ module RedmineHooks class GithubIssuesSync < Base - include HttpHelper - def call sync_with_github end - def project object end - def params payloads end - private + def github_issue + GithubIssue.find_by_github_id params[:issue][:id] + end - def github_issue - GithubIssue.find_by_github_id(params[:issue][:id]) - end - + def redmine_issue + Issue.find_by_subject params[:issue][:title] + end - def redmine_issue - Issue.find_by_subject(params[:issue][:title]) + def sync_with_github + create_relation = false + + ## We don't have stored relation + if github_issue.nil? + create_relation = true + + ## And we don't have issue in Redmine + redmine_issue = if redmine_issue.nil? + create_redmine_issue + else + ## Create relation and update issue + update_redmine_issue(redmine_issue) + end + else + ## We have one relation, update issue + redmine_issue = update_redmine_issue(github_issue.issue) end - - def sync_with_github - create_relation = false - - ## We don't have stored relation - if github_issue.nil? - - ## And we don't have issue in Redmine - if redmine_issue.nil? - create_relation = true - redmine_issue = create_redmine_issue - else - ## Create relation and update issue - create_relation = true - redmine_issue = update_redmine_issue(redmine_issue) - end - else - ## We have one relation, update issue - redmine_issue = update_redmine_issue(github_issue.issue) - end - - if create_relation - github_issue = GithubIssue.new - github_issue.github_id = params[:issue][:id] - github_issue.issue_id = redmine_issue.id - github_issue.save! - end - - if params.has_key?(:comment) - issue_journal = GithubComment.find_by_github_id(params[:comment][:id]) - - if issue_journal.nil? - issue_journal = create_issue_journal(github_issue.issue) - - github_comment = GithubComment.new - github_comment.github_id = params[:comment][:id] - github_comment.journal_id = issue_journal.id - github_comment.save! - end - end + if create_relation + github_issue = GithubIssue.new + github_issue.github_id = params[:issue][:id] + github_issue.issue_id = redmine_issue.id + github_issue.save! end + if params.key?(:comment) + issue_journal = GithubComment.find_by_github_id(params[:comment][:id]) - def create_redmine_issue - logger.info('Github Issues Sync : create new issue') - - issue = project.issues.new - issue.tracker_id = project.trackers.first.try(:id) - issue.subject = params[:issue][:title].chomp[0, 255] - issue.description = params[:issue][:body] - issue.updated_on = params[:issue][:updated_at] - issue.created_on = params[:issue][:created_at] - - ## Get user mail - user = find_user(params[:issue][:user][:url]) - issue.author = user + if issue_journal.nil? + issue_journal = create_issue_journal(github_issue.issue) - issue.save! - return issue + github_comment = GithubComment.new + github_comment.github_id = params[:comment][:id] + github_comment.journal_id = issue_journal.id + github_comment.save! + end end + end + def create_redmine_issue + logger.info('Github Issues Sync : create new issue') - def create_issue_journal(issue) - logger.info("Github Issues Sync : create new journal for issue '##{issue.id}'") + issue = project.issues.new + issue.tracker_id = project.trackers.first.try(:id) + issue.subject = params[:issue][:title].chomp[0, 255] + issue.description = params[:issue][:body] + issue.updated_on = params[:issue][:updated_at] + issue.created_on = params[:issue][:created_at] - journal = Journal.new - journal.journalized_id = issue.id - journal.journalized_type = 'Issue' - journal.notes = params[:comment][:body] - journal.created_on = params[:comment][:created_at] + ## Get user mail + user = find_user(params[:issue][:user][:url]) + issue.author = user - ## Get user mail - user = find_user(params[:comment][:user][:url]) - journal.user_id = user.id + issue.save! + issue + end - journal.save! - return journal - end + def create_issue_journal(issue) + logger.info("Github Issues Sync : create new journal for issue '##{issue.id}'") + journal = Journal.new + journal.journalized_id = issue.id + journal.journalized_type = 'Issue' + journal.notes = params[:comment][:body] + journal.created_on = params[:comment][:created_at] - def update_redmine_issue(issue) - logger.info("Github Issues Sync : update issue '##{issue.id}'") + ## Get user mail + user = find_user(params[:comment][:user][:url]) + journal.user_id = user.id - if params[:issue][:state] == 'closed' - issue.status_id = 5 - else - issue.status_id = 1 - end + journal.save! + journal + end - issue.subject = params[:issue][:title].chomp[0, 255] - issue.description = params[:issue][:body] - issue.updated_on = params[:issue][:updated_at] + def update_redmine_issue(issue) + logger.info("Github Issues Sync : update issue '##{issue.id}'") - issue.save! - return issue - end + issue.status_id = if params[:issue][:state] == 'closed' + 5 + else + 1 + end + issue.subject = params[:issue][:title].chomp[0, 255] + issue.description = params[:issue][:body] + issue.updated_on = params[:issue][:updated_at] - def find_user(url) - post_failed, user_data = http_get(url) - user_data = JSON.parse(user_data) + issue.save! + issue + end - user = User.find_by_mail(user_data['email']) + def find_user(url) + post_failed, user_data = http_get(url) + user_data = JSON.parse(user_data) - if user.nil? - logger.info("Github Issues Sync : cannot find user '#{user_data['email']}' in Redmine, use anonymous") - user = User.anonymous - user.mail = user_data['email'] - user.firstname = user_data['name'] - user.lastname = user_data['login'] - end + user = User.find_by_mail(user_data['email']) - return user + if user.nil? + logger.info("Github Issues Sync : cannot find user '#{user_data['email']}' in Redmine, use anonymous") + user = User.anonymous + user.mail = user_data['email'] + user.firstname = user_data['name'] + user.lastname = user_data['login'] end + user + end end end diff --git a/app/services/redmine_hooks/http_helper.rb b/app/services/redmine_hooks/http_helper.rb index 0ce3b91fae4..68bb023b988 100644 --- a/app/services/redmine_hooks/http_helper.rb +++ b/app/services/redmine_hooks/http_helper.rb @@ -1,14 +1,11 @@ module RedmineHooks module HttpHelper - def http_post(url, opts = {}) - RedmineGitHosting::Utils::Http.http_post(url, opts) + RedmineGitHosting::Utils::Http.http_post url, opts end - def http_get(url, opts = {}) - RedmineGitHosting::Utils::Http.http_get(url, opts) + RedmineGitHosting::Utils::Http.http_get url, opts end - end end diff --git a/app/services/redmine_hooks/update_mirrors.rb b/app/services/redmine_hooks/update_mirrors.rb index 07623353dc0..64a1591f09b 100644 --- a/app/services/redmine_hooks/update_mirrors.rb +++ b/app/services/redmine_hooks/update_mirrors.rb @@ -1,6 +1,5 @@ module RedmineHooks class UpdateMirrors < Base - def call execute_hook do |out| if needs_push? @@ -12,60 +11,53 @@ def call end end - def mirror object end - # If we have an explicit refspec, check it against incoming payloads # Special case: if we do not pass in any payloads, return true def needs_push? return true if payloads.empty? return true if mirror.mirror_mode? - return check_ref_spec - end + check_ref_spec + end def start_message "Pushing changes to #{mirror.url}" end - def skip_message "This mirror doesn't need to be updated" end - private + def check_ref_spec + refspec_parse = RedmineGitHosting::Validators.valid_git_refspec?(mirror.explicit_refspec) + payloads.each do |payload| + next unless splitpath = RedmineGitHosting::Utils::Git.parse_refspec(payload[:ref]) - def check_ref_spec - refspec_parse = RedmineGitHosting::Validators.valid_git_refspec?(mirror.explicit_refspec) - payloads.each do |payload| - if splitpath = RedmineGitHosting::Utils::Git.parse_refspec(payload[:ref]) - return true if payload[:ref] == refspec_parse[1] # Explicit Reference Spec complete path - return true if splitpath[:name] == refspec_parse[1] # Explicit Reference Spec no type - return true if mirror.include_all_branches? && splitpath[:type] == 'heads' - return true if mirror.include_all_tags? && splitpath[:type] == 'tags' - end - end - false + return true if payload[:ref] == refspec_parse[1] # Explicit Reference Spec complete path + return true if splitpath[:name] == refspec_parse[1] # Explicit Reference Spec no type + return true if mirror.include_all_branches? && splitpath[:type] == 'heads' + return true if mirror.include_all_tags? && splitpath[:type] == 'tags' end + false + end + def call_mirror + push_failed, push_message = RepositoryMirrors::Push.call(mirror) - def call_mirror - push_failed, push_message = RepositoryMirrors::Push.call(mirror) - - if push_failed - log_hook_failed - logger.error(push_message) - failure_message - else - log_hook_succeeded - success_message - end + if push_failed + log_hook_failed + logger.error(push_message) + failure_message + else + log_hook_succeeded + success_message end - + end end end diff --git a/app/use_cases/gitolite_public_keys/generate_identifier.rb b/app/use_cases/gitolite_public_keys/generate_identifier.rb index 38b5c080b90..d905be683a5 100644 --- a/app/use_cases/gitolite_public_keys/generate_identifier.rb +++ b/app/use_cases/gitolite_public_keys/generate_identifier.rb @@ -1,12 +1,8 @@ module GitolitePublicKeys class GenerateIdentifier + DEPLOY_PSEUDO_USER = 'deploy_key'.freeze - DEPLOY_PSEUDO_USER = 'deploy_key' - - attr_reader :public_key - attr_reader :user - attr_reader :skip_auto_increment - + attr_reader :public_key, :user, :skip_auto_increment def initialize(public_key, user, opts = {}) @public_key = public_key @@ -14,16 +10,12 @@ def initialize(public_key, user, opts = {}) @skip_auto_increment = opts.delete(:skip_auto_increment) { false } end - class << self - def call(public_key, user, opts = {}) new(public_key, user, opts).call end - end - # Returns the unique identifier for this key based on the key_type # # For user public keys, this simply is the user's gitolite_identifier. @@ -37,36 +29,31 @@ def call end end - private + def set_identifier_for_user_key + tag = public_key.title.gsub(/[^0-9a-zA-Z]/, '_') + [user.gitolite_identifier, '@', 'redmine_', tag].join + end - def set_identifier_for_user_key - tag = public_key.title.gsub(/[^0-9a-zA-Z]/, '_') - [user.gitolite_identifier, '@', 'redmine_', tag].join - end - - - # Fix https://github.com/jbox-web/redmine_git_hosting/issues/288 - # Getting user deployment keys count is not sufficient to assure uniqueness of - # deployment key identifier. So we need an 'external' counter to increment the global count - # while a key with this identifier exists. - # - def set_identifier_for_deploy_key - count = 0 - begin - key_id = generate_deploy_key_identifier(count) - count += 1 - end while user.gitolite_public_keys.deploy_key.map(&:owner).include?(key_id.split('@')[0]) - key_id - end - - - def generate_deploy_key_identifier(count) - key_count = 1 + count - key_count += user.gitolite_public_keys.deploy_key.length unless skip_auto_increment - [user.gitolite_identifier, '_', DEPLOY_PSEUDO_USER, '_', key_count, '@', 'redmine_', DEPLOY_PSEUDO_USER, '_', key_count].join - end + # Fix https://github.com/jbox-web/redmine_git_hosting/issues/288 + # Getting user deployment keys count is not sufficient to assure uniqueness of + # deployment key identifier. So we need an 'external' counter to increment the global count + # while a key with this identifier exists. + # + def set_identifier_for_deploy_key + count = 0 + begin + key_id = generate_deploy_key_identifier(count) + count += 1 + end while user.gitolite_public_keys.deploy_key.map(&:owner).include?(key_id.split('@')[0]) + key_id + end + def generate_deploy_key_identifier(count) + key_count = 1 + count + key_count += user.gitolite_public_keys.deploy_key.length unless skip_auto_increment + [user.gitolite_identifier, '_', DEPLOY_PSEUDO_USER, '_', key_count, '@', 'redmine_', DEPLOY_PSEUDO_USER, '_', key_count].join + end end end diff --git a/app/use_cases/projects/base.rb b/app/use_cases/projects/base.rb index 99693573127..d8b502d76d2 100644 --- a/app/use_cases/projects/base.rb +++ b/app/use_cases/projects/base.rb @@ -1,30 +1,22 @@ module Projects class Base - include RedmineGitHosting::GitoliteAccessor::Methods - attr_reader :project - attr_reader :options - + attr_reader :project, :options def initialize(project, opts = {}) @project = project @options = opts end - class << self - def call(project, opts = {}) new(project, opts).call end - end - def call raise NotImplementedError end - end end diff --git a/app/use_cases/projects/create_repository.rb b/app/use_cases/projects/create_repository.rb index c6acfe327c0..009b68e1ae3 100644 --- a/app/use_cases/projects/create_repository.rb +++ b/app/use_cases/projects/create_repository.rb @@ -1,32 +1,27 @@ module Projects class CreateRepository < Base - def call create_project_repository end - private + def create_project_repository + # Create new repository + repository = Repository.factory('Xitolite') + repository.is_default = true + repository.extra_info = {} + repository.extra_info['extra_report_last_commit'] = '1' - def create_project_repository - # Create new repository - repository = Repository.factory('Xitolite') - repository.is_default = true - repository.extra_info = {} - repository.extra_info['extra_report_last_commit'] = '1' - - # Save it to database - project.repositories << repository - - # Create it in Gitolite - Repositories::Create.call(repository, creation_options) - end + # Save it to database + project.repositories << repository + # Create it in Gitolite + Repositories::Create.call(repository, creation_options) + end - def creation_options - { create_readme_file: RedmineGitHosting::Config.init_repositories_on_create? } - end - + def creation_options + { create_readme_file: RedmineGitHosting::Config.init_repositories_on_create? } + end end end diff --git a/app/use_cases/projects/execute_hooks.rb b/app/use_cases/projects/execute_hooks.rb index 52081274dcb..adcb3d542e1 100644 --- a/app/use_cases/projects/execute_hooks.rb +++ b/app/use_cases/projects/execute_hooks.rb @@ -1,10 +1,6 @@ module Projects class ExecuteHooks - - attr_reader :project - attr_reader :hook_type - attr_reader :params - + attr_reader :project, :hook_type, :params def initialize(project, hook_type, params = {}) @project = project @@ -12,27 +8,20 @@ def initialize(project, hook_type, params = {}) @params = params end - class << self - def call(project, hook_type, params = {}) new(project, hook_type, params).call end - end - def call - self.send("execute_#{hook_type}_hook") + send("execute_#{hook_type}_hook") end - private - - def execute_github_hook - RedmineHooks::GithubIssuesSync.call(project, params) - end - + def execute_github_hook + RedmineHooks::GithubIssuesSync.call(project, params) + end end end diff --git a/app/use_cases/projects/update.rb b/app/use_cases/projects/update.rb index e4a56303d4a..1d30a2342f1 100644 --- a/app/use_cases/projects/update.rb +++ b/app/use_cases/projects/update.rb @@ -1,29 +1,24 @@ module Projects class Update < Base - def call # Adjust daemon status disable_git_daemon_if_not_public resync end - private - - def disable_git_daemon_if_not_public - # Go through all gitolite repos and disable Git daemon if necessary - project.gitolite_repos.each do |repository| - repository.extra[:git_daemon] = false if repository.git_daemon_enabled? && !project.is_public - # Save GitExtra in all cases to trigger urls order consistency checks - repository.extra.save - end - end - - - def resync - gitolite_accessor.update_projects([project.id], options) + def disable_git_daemon_if_not_public + # Go through all gitolite repos and disable Git daemon if necessary + project.gitolite_repos.each do |repository| + repository.extra[:git_daemon] = false if repository.git_daemon_enabled? && !project.is_public + # Save GitExtra in all cases to trigger urls order consistency checks + repository.extra.save end + end + def resync + gitolite_accessor.update_projects([project.id], options) + end end end diff --git a/app/use_cases/repositories/base.rb b/app/use_cases/repositories/base.rb index 452e22cc42b..bca556a3368 100644 --- a/app/use_cases/repositories/base.rb +++ b/app/use_cases/repositories/base.rb @@ -1,12 +1,8 @@ module Repositories class Base - include RedmineGitHosting::GitoliteAccessor::Methods - attr_reader :repository - attr_reader :options - attr_reader :project - + attr_reader :repository, :options, :project def initialize(repository, opts = {}) @repository = repository @@ -14,27 +10,20 @@ def initialize(repository, opts = {}) @project = repository.project end - class << self - def call(repository, opts = {}) new(repository, opts).call end - end - def call raise NotImplementedError end - private - - def logger - RedmineGitHosting.logger - end - + def logger + RedmineGitHosting.logger + end end end diff --git a/app/use_cases/repositories/build_payload.rb b/app/use_cases/repositories/build_payload.rb index 2da19459b4b..c0e9022635a 100644 --- a/app/use_cases/repositories/build_payload.rb +++ b/app/use_cases/repositories/build_payload.rb @@ -1,91 +1,83 @@ module Repositories class BuildPayload < Base - def initialize(*args) super @payloads = [] end - def call build_payloads end - def refs options end - private + # Returns an array of GitHub post-receive hook style hashes + # http://help.github.com/post-receive-hooks/ + # + def build_payloads + refs.each do |ref| + # Get revisions range + range = get_revisions_from_ref(ref) + next if range.nil? - # Returns an array of GitHub post-receive hook style hashes - # http://help.github.com/post-receive-hooks/ - # - def build_payloads - refs.each do |ref| - # Get revisions range - range = get_revisions_from_ref(ref) - next if range.nil? - @payloads << build_payload(ref, range) - end - @payloads + @payloads << build_payload(ref, range) end + @payloads + end - - def get_revisions_from_ref(ref) - oldhead, newhead, refname = ref.split(',') - - # Only pay attention to branch updates - return nil if !refname.match(/refs\/heads\//) - - # Get branch name - branch_name = refname.gsub('refs/heads/', '') - - if newhead.match(/\A0{40}\z/) - # Deleting a branch - logger.info("Deleting branch '#{branch_name}'") - range = nil - elsif oldhead.match(/\A0{40}\z/) - # Creating a branch - logger.info("Creating branch '#{branch_name}'") - range = newhead - else - range = "#{oldhead}..#{newhead}" - end - - range + def get_revisions_from_ref(ref) + oldhead, newhead, refname = ref.split ',' + + # Only pay attention to branch updates + return nil if !refname.match(/refs\/heads\//) + + # Get branch name + branch_name = refname.gsub('refs/heads/', '') + + if newhead.match(/\A0{40}\z/) + # Deleting a branch + logger.info("Deleting branch '#{branch_name}'") + range = nil + elsif oldhead.match(/\A0{40}\z/) + # Creating a branch + logger.info("Creating branch '#{branch_name}'") + range = newhead + else + range = "#{oldhead}..#{newhead}" end + range + end - def build_payload(ref, range) - revisions_in_range = get_revisions_in_range(range) - logger.debug("Revisions in range : #{revisions_in_range.join(' ')}") - - # Get refs - oldhead, newhead, refname = ref.split(',') - - # Build payload hash - repository.github_payload - .merge({ before: oldhead, after: newhead, ref: refname, commits: build_commits_list(revisions_in_range) }) - end + def build_payload(ref, range) + revisions_in_range = get_revisions_in_range(range) + logger.debug("Revisions in range : #{revisions_in_range.join(' ')}") + # Get refs + oldhead, newhead, refname = ref.split ',' - def build_commits_list(revisions_in_range) - commits_list = [] - revisions_in_range.each do |rev| - changeset = repository.find_changeset_by_name(rev) - next if changeset.nil? - commits_list << changeset.github_payload - end - commits_list - end + # Build payload hash + repository.github_payload + .merge({ before: oldhead, after: newhead, ref: refname, commits: build_commits_list(revisions_in_range) }) + end + def build_commits_list(revisions_in_range) + commits_list = [] + revisions_in_range.each do |rev| + changeset = repository.find_changeset_by_name(rev) + next if changeset.nil? - def get_revisions_in_range(range) - repository.rev_list(range, ['--reverse']) + commits_list << changeset.github_payload end + commits_list + end + def get_revisions_in_range(range) + repository.rev_list(range, ['--reverse']) + end end end diff --git a/app/use_cases/repositories/create.rb b/app/use_cases/repositories/create.rb index 250aefae6c2..7ffb8b7ab71 100644 --- a/app/use_cases/repositories/create.rb +++ b/app/use_cases/repositories/create.rb @@ -1,71 +1,61 @@ module Repositories class Create < Base - def call set_repository_extra create_repository end - private + def set_repository_extra + extra = repository.build_extra(default_extra_options) + extra.save! + end - def set_repository_extra - extra = repository.build_extra(default_extra_options) - extra.save! - end - - - def default_extra_options - enable_git_annex? ? git_annex_repository_options : standard_repository_options - end - - - def enable_git_annex? - options[:enable_git_annex] - end - - - def standard_repository_options - { - git_daemon: RedmineGitHosting::Config.gitolite_daemon_by_default?, - git_notify: RedmineGitHosting::Config.gitolite_notify_by_default?, - git_annex: false, - default_branch: 'master', - key: RedmineGitHosting::Utils::Crypto.generate_secret(64) - }.merge(smart_http_options) - end - + def default_extra_options + enable_git_annex? ? git_annex_repository_options : standard_repository_options + end - def smart_http_options - case RedmineGitHosting::Config.gitolite_http_by_default? - when '1' # HTTPS only - { git_https: true } - when '2' # HTTPS and HTTP - { git_http: true, git_https: true } - when '3' # HTTP only - { git_http: true } - else - {} - end - end + def enable_git_annex? + options[:enable_git_annex] + end + def standard_repository_options + { + git_daemon: RedmineGitHosting::Config.gitolite_daemon_by_default?, + git_notify: RedmineGitHosting::Config.gitolite_notify_by_default?, + git_annex: false, + default_branch: 'master', + key: RedmineGitHosting::Utils::Crypto.generate_secret(64) + }.merge(smart_http_options) + end - def git_annex_repository_options - { - git_http: 0, - git_daemon: false, - git_notify: false, - git_annex: true, - default_branch: 'git-annex', - key: RedmineGitHosting::Utils::Crypto.generate_secret(64) - } + def smart_http_options + case RedmineGitHosting::Config.gitolite_http_by_default? + when '1' # HTTPS only + { git_https: true } + when '2' # HTTPS and HTTP + { git_http: true, git_https: true } + when '3' # HTTP only + { git_http: true } + else + {} end + end + def git_annex_repository_options + { + git_http: 0, + git_daemon: false, + git_notify: false, + git_annex: true, + default_branch: 'git-annex', + key: RedmineGitHosting::Utils::Crypto.generate_secret(64) + } + end - def create_repository - gitolite_accessor.create_repository(repository, options) - end - + def create_repository + gitolite_accessor.create_repository(repository, options) + end end end diff --git a/app/use_cases/repositories/download_revision.rb b/app/use_cases/repositories/download_revision.rb index 74dcbee39cf..3df9928d209 100644 --- a/app/use_cases/repositories/download_revision.rb +++ b/app/use_cases/repositories/download_revision.rb @@ -1,15 +1,6 @@ module Repositories class DownloadRevision - - attr_reader :repository - attr_reader :revision - attr_reader :format - attr_reader :gitolite_repository_path - - attr_reader :commit_id - attr_reader :content_type - attr_reader :filename - + attr_reader :repository, :revision, :format, :gitolite_repository_path, :commit_id, :content_type, :filename def initialize(repository, revision, format) @repository = repository @@ -26,68 +17,62 @@ def initialize(repository, revision, format) fill_data end - def content repository.archive(commit_id, format) end - def valid_commit? @valid_commit end - private + def validate_revision + commit = nil - def validate_revision - commit = nil - - # is the revision a branch? - repository.branches.each do |x| - if x.to_s == revision - commit = x.revision - break - end + # is the revision a branch? + repository.branches.each do |x| + if x.to_s == revision + commit = x.revision + break end + end - # is the revision a tag? - if commit.nil? - repository.tags.each do |x| - if x == revision - commit = repository.rev_list(revision).first - break - end + # is the revision a tag? + if commit.nil? + repository.tags.each do |x| + if x == revision + commit = repository.rev_list(revision).first + break end end - - # well, let check if this is a valid commit - commit = revision if commit.nil? - commit = repository.rev_parse(commit) - - if commit == '' - @valid_commit = false - else - @valid_commit = true - @commit_id = commit - end end + # well, let check if this is a valid commit + commit = revision if commit.nil? + commit = repository.rev_parse(commit) - def fill_data - case format - when 'tar.gz' then - extension = 'tar.gz' - @content_type = 'application/x-gzip' - when 'zip' then - extension = 'zip' - @content_type = 'application/x-zip' - else - extension = 'tar' - @content_type = 'application/x-tar' - end - @filename = "#{repository.redmine_name}-#{revision}.#{extension}" + if commit == '' + @valid_commit = false + else + @valid_commit = true + @commit_id = commit end + end + def fill_data + case format + when 'tar.gz' + extension = 'tar.gz' + @content_type = 'application/x-gzip' + when 'zip' + extension = 'zip' + @content_type = 'application/x-zip' + else + extension = 'tar' + @content_type = 'application/x-tar' + end + @filename = "#{repository.redmine_name}-#{revision}.#{extension}" + end end end diff --git a/app/use_cases/repositories/execute_hooks.rb b/app/use_cases/repositories/execute_hooks.rb index 57a651aa544..15d1df53cac 100644 --- a/app/use_cases/repositories/execute_hooks.rb +++ b/app/use_cases/repositories/execute_hooks.rb @@ -1,10 +1,6 @@ module Repositories class ExecuteHooks - - attr_reader :repository - attr_reader :hook_type - attr_reader :payloads - + attr_reader :repository, :hook_type, :payloads def initialize(repository, hook_type, payloads = {}) @repository = repository @@ -12,68 +8,58 @@ def initialize(repository, hook_type, payloads = {}) @payloads = payloads end - class << self - def call(repository, hook_type, payloads = {}) new(repository, hook_type, payloads).call end - end - def call - self.send("execute_#{hook_type}_hook") + send("execute_#{hook_type}_hook") end - private + def logger + RedmineGitHosting.logger + end - def logger - RedmineGitHosting.logger - end - - - def execute_fetch_changesets_hook - RedmineHooks::FetchChangesets.call(repository) - end - + def execute_fetch_changesets_hook + RedmineHooks::FetchChangesets.call(repository) + end - def execute_update_mirrors_hook - message = 'Notifying mirrors about changes to this repository :' - y = '' + def execute_update_mirrors_hook + message = 'Notifying mirrors about changes to this repository:' + y = '' - ## Post to each post-receive URL - if repository.mirrors.active.any? - logger.info(message) - y << "\n#{message}\n" + ## Post to each post-receive URL + if repository.mirrors.active.any? + logger.info(message) + y << "\n#{message}\n" - repository.mirrors.active.each do |mirror| - y << RedmineHooks::UpdateMirrors.call(mirror, payloads) - end + repository.mirrors.active.each do |mirror| + y << RedmineHooks::UpdateMirrors.call(mirror, payloads) end - - y end + y + end - def execute_call_webservices_hook - message = 'Notifying post receive urls about changes to this repository :' - y = '' + def execute_call_webservices_hook + message = 'Notifying post receive urls about changes to this repository:' + y = '' - ## Post to each post-receive URL - if repository.post_receive_urls.active.any? - logger.info(message) - y << "\n#{message}\n" + ## Post to each post-receive URL + if repository.post_receive_urls.active.any? + logger.info(message) + y << "\n#{message}\n" - repository.post_receive_urls.active.each do |post_receive_url| - y << RedmineHooks::CallWebservices.call(post_receive_url, payloads) - end + repository.post_receive_urls.active.each do |post_receive_url| + y << RedmineHooks::CallWebservices.call(post_receive_url, payloads) end - - y end + y + end end end diff --git a/app/use_cases/repository_mirrors/base.rb b/app/use_cases/repository_mirrors/base.rb index 3ca5fd97737..d7fcaa92698 100644 --- a/app/use_cases/repository_mirrors/base.rb +++ b/app/use_cases/repository_mirrors/base.rb @@ -1,28 +1,20 @@ module RepositoryMirrors class Base - - attr_reader :mirror - attr_reader :repository - + attr_reader :mirror, :repository def initialize(mirror) @mirror = mirror @repository = mirror.repository end - class << self - def call(mirror) new(mirror).call end - end - def call raise NotImplementedError end - end end diff --git a/app/use_cases/repository_mirrors/push.rb b/app/use_cases/repository_mirrors/push.rb index b297bca9db9..eb14e0f2241 100644 --- a/app/use_cases/repository_mirrors/push.rb +++ b/app/use_cases/repository_mirrors/push.rb @@ -1,11 +1,9 @@ module RepositoryMirrors class Push < Base - def call push! end - def push! begin push_message = repository.mirror_push(*command) @@ -18,38 +16,31 @@ def push! return push_failed, push_message end - def command [mirror.url, branch, push_args] end - private + def push_args + mirror.mirror_mode? ? ['--mirror'] : mirror_args + end - def push_args - mirror.mirror_mode? ? ['--mirror'] : mirror_args - end - - - def mirror_args - push_args = [] - push_args << '--force' if mirror.force_mode? - push_args << '--all' if mirror.include_all_branches? - push_args << '--tags' if mirror.include_all_tags? - push_args - end - - - def branch - "#{dequote(mirror.explicit_refspec)}" unless mirror.explicit_refspec.blank? - end - + def mirror_args + push_args = [] + push_args << '--force' if mirror.force_mode? + push_args << '--all' if mirror.include_all_branches? + push_args << '--tags' if mirror.include_all_tags? + push_args + end - # Put backquote in front of crucial characters - def dequote(in_string) - in_string.gsub(/[$,"\\\n]/) { |x| "\\" + x } - end + def branch + "#{dequote(mirror.explicit_refspec)}" unless mirror.explicit_refspec.blank? + end + # Put backquote in front of crucial characters + def dequote(in_string) + in_string.gsub(/[$,"\\\n]/) { |x| "\\" + x } + end end end diff --git a/app/use_cases/repository_protected_branches/member_manager.rb b/app/use_cases/repository_protected_branches/member_manager.rb index f4f3886d77f..5939b3a452d 100644 --- a/app/use_cases/repository_protected_branches/member_manager.rb +++ b/app/use_cases/repository_protected_branches/member_manager.rb @@ -1,39 +1,31 @@ module RepositoryProtectedBranches class MemberManager - attr_reader :protected_branch - def initialize(protected_branch) @protected_branch = protected_branch end - def current_user_ids protected_branch.users.map(&:id) end - def current_group_ids protected_branch.groups.map(&:id) end - def current_members protected_branch.protected_branches_members end - def users_by_group_id(id) current_members.select { |pbm| pbm.principal.class.name == 'User' && pbm.inherited_by == id }.map(&:principal) end - def add_users(ids) create_user_member(ids, current_user_ids) end - def add_groups(ids) create_group_member(ids, current_group_ids) do |group| ids = group.users.map(&:id) @@ -42,31 +34,27 @@ def add_groups(ids) end end - def create_user_member(ids, current_ids, opts = {}, &block) create_member(ids, current_ids, 'User', opts, &block) end - def create_group_member(ids, current_ids, opts = {}, &block) create_member(ids, current_ids, 'Group', opts, &block) end - def add_user_from_group(user, group_id) ids = users_by_group_id(group_id).push(user).map(&:id) current_ids = users_by_group_id(group_id).map(&:id) create_user_member(ids, current_ids, inherited_by: group_id, destroy: false) end - def remove_user_from_group(user, group_id) return unless users_by_group_id(group_id).include?(user) + member = current_members.find_by_protected_branch_id_and_principal_id_and_inherited_by(protected_branch.id, user.id, group_id) - member.destroy! unless member.nil? + member&.destroy! end - def create_member(ids, current_ids, klass, opts = {}, &block) destroy = opts.fetch(:destroy, true) inherited_by = opts.fetch(:inherited_by, nil) @@ -77,6 +65,7 @@ def create_member(ids, current_ids, klass, opts = {}, &block) new_ids.each do |id| object = klass.constantize.find_by_id(id) next if object.nil? + current_members.create(principal_id: object.id, inherited_by: inherited_by) yield object if block_given? end @@ -86,6 +75,5 @@ def create_member(ids, current_ids, klass, opts = {}, &block) member_to_destroy.each(&:destroy) if member_to_destroy.any? end end - end end diff --git a/app/use_cases/settings/apply.rb b/app/use_cases/settings/apply.rb index 3bf06587b2f..1a3d534a5a7 100644 --- a/app/use_cases/settings/apply.rb +++ b/app/use_cases/settings/apply.rb @@ -2,12 +2,7 @@ module Settings class Apply include RedmineGitHosting::GitoliteAccessor::Methods - attr_reader :previous_settings - attr_reader :resync_projects - attr_reader :resync_ssh_keys - attr_reader :regenerate_ssh_keys - attr_reader :flush_cache - attr_reader :delete_trash_repo + attr_reader :previous_settings, :resync_projects, :resync_ssh_keys, :regenerate_ssh_keys, :flush_cache, :delete_trash_repo def initialize(previous_settings, opts = {}) @previous_settings = previous_settings @@ -75,7 +70,7 @@ def check_repo_hierarchy # Need to update everyone! # We take all root projects (even those who are closed) and move each hierarchy individually - count = Project.includes(:repositories).all.select { |x| x if x.parent_id.nil? }.length + count = Project.includes(:repositories).all.count { |x| x if x.parent_id.nil? } gitolite_accessor.move_repositories_tree(count) if count.positive? end end diff --git a/app/views/archived_repositories/_dir_list_content.html.erb b/app/views/archived_repositories/_dir_list_content.html.erb deleted file mode 100644 index 63d15fec9d6..00000000000 --- a/app/views/archived_repositories/_dir_list_content.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<% @entries.each do |entry| %> -<% tr_id = Digest::MD5.hexdigest(entry.path) - depth = params[:depth].to_i %> -<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %> -<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> - -"> -<% if entry.is_dir? %> -  -<% end %> -<%= link_to h(ent_name), - {:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, - :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> - -<%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %> -<% if @repository.report_last_commit %> -<%= link_to_revision2(entry.changeset, @repository) if entry.changeset %> -<%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> -<%= entry.author %> -<%= entry.changeset.comments.truncate(50) if entry.changeset %> -<% end %> - -<% end %> diff --git a/app/views/archived_repositories/_revisions.html.erb b/app/views/archived_repositories/_revisions.html.erb deleted file mode 100644 index ebaf6a7176a..00000000000 --- a/app/views/archived_repositories/_revisions.html.erb +++ /dev/null @@ -1,51 +0,0 @@ -<% show_revision_graph = ( @repository.supports_revision_graph? && path.blank? ) %> -<%= if show_revision_graph && revisions && revisions.any? - indexed_commits, graph_space = index_commits(revisions, @repository.branches) do |scmid| - url_for( - :controller => 'archived_repositories', - :action => 'revision', - :id => project, - :repository_id => @repository.identifier_param, - :rev => scmid) - end - render :partial => 'revision_graph', - :locals => { - :commits => indexed_commits, - :space => graph_space - } -end %> -<%= form_tag( - {:controller => 'archived_repositories', :action => 'diff', :id => project, - :repository_id => @repository.identifier_param, :path => to_path_param(path)}, - :method => :get - ) do %> - - - - - - - - - - -<% show_diff = revisions.size > 1 %> -<% line_num = 1 %> -<% revisions.each do |changeset| %> - -<% id_style = (show_revision_graph ? "padding-left:#{(graph_space + 1) * 20}px" : nil) %> -<%= content_tag(:td, :class => 'id', :style => id_style) do %> - <%= link_to_revision2(changeset, @repository) %> -<% end %> - - - - - - -<% line_num += 1 %> -<% end %> - -
#<%= l(:label_date) %><%= l(:field_author) %><%= l(:field_comments) %>
<%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked',true);") if show_diff && (line_num < revisions.size) %><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %><%= format_time(changeset.committed_on) %><%= changeset.author.to_s.truncate(30) %><%= textilizable(truncate_at_line_break(changeset.comments)) %>
-<%= submit_tag(l(:label_view_diff), :name => nil) if show_diff %> -<% end %> diff --git a/app/views/archived_repositories/annotate.html.erb b/app/views/archived_repositories/annotate.html.erb deleted file mode 100644 index 554a6e3cefc..00000000000 --- a/app/views/archived_repositories/annotate.html.erb +++ /dev/null @@ -1,46 +0,0 @@ -<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> - -
- <%= render :partial => 'navigation' %> -
- -

<%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

- -<%= render :partial => 'link_to_functions' %> - -<% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %> - -
- - - <% line_num = 1; previous_revision = nil %> - <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> - <% revision = @annotate.revisions[line_num - 1] %> - - - - - - - <% line_num += 1; previous_revision = revision %> - <% end %> - -
<%= line_num %> - <% if revision && revision != previous_revision %> - <%= revision.identifier ? - link_to_revision2(revision, @repository) : format_revision(revision) %> - <% end %> - - <% if revision && revision != previous_revision %> - <% author = Redmine::CodesetUtil.to_utf8(revision.author.to_s, - @repository.repo_log_encoding) %> - <%= author.split('<').first %> - <% end %> -
<%= line.html_safe %>
-
- -<% html_title(l(:button_annotate)) -%> - -<% content_for :header_tags do %> -<%= stylesheet_link_tag 'scm' %> -<% end %> diff --git a/app/views/archived_repositories/git_instructions.html.erb b/app/views/archived_repositories/git_instructions.html.erb deleted file mode 100644 index cc124d7f7be..00000000000 --- a/app/views/archived_repositories/git_instructions.html.erb +++ /dev/null @@ -1,89 +0,0 @@ -<%# This is used to display basic git setup instructions, like on github... %> -<% flash.now[:warning] = l(:notice_empty_repository) %> - -
- <% if User.current.allowed_to?(:view_changesets, @project) %> -

<%= l(:label_help_git_setup) %> :

- -
-      <%= l(:label_download_and_install_git) %>
-      git config --global user.name "<%= User.current.name(:firstname_lastname) %>"
-      git config --global user.email <%= User.current.mail ? User.current.mail : "mail@example.com" %>
-      <% if !User.current.anonymous? && User.current.gitolite_public_keys.active.length == 0 %>
-      <%= link_to "Upload SSH Public Key", {:controller => 'my', :action => 'account'} %>
-      <% end %>
-    
- - <% if User.current.allowed_to?(:commit_access, @project) %> -
-

<%= l(:label_help_repository_setup_new) %> :

-
-      mkdir <%= @repository.redmine_name %>
-      cd <%= @repository.redmine_name %>
-      git init
-      touch readme.txt
-      git add readme.txt
-      git commit -m 'Initializing <%= @repository.redmine_name %> repository'
-      git remote add origin 
-      git push -u origin master
-    
- -

<%= l(:label_help_repository_setup_existing) %> :

-
-      cd existing_git_repo
-      git remote add origin 
-      git push -u origin master
-    
-
- <% end %> - -

<%= l(:label_help_repository_clone) %> :

-
-      git clone 
-    
- <% else %> - <%= l(:label_help_no_repo_rights) %> - <% end %> -
- -<% content_for :sidebar do %> -

<%= l(:label_repository_plural) %>

-
    - <% @repositories.sort.each do |repo| %> -
  • <%= link_to h(repo.name), {:controller => 'archived_repositories', :action => 'show', :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, - :class => 'repository' + (@repository.is_a?(Repository::Xitolite) ? ' git' : '') + (repo == @repository ? ' selected' : '') %> -
  • - <% end %> -
- - <% if @repository.is_a?(Repository::Xitolite) && @repository.urls_are_viewable? %> -
-

<%= l(:label_repository_access_url) %>

- <%= render :partial => 'common/git_urls', :locals => {:repository => @repository} %> -
- <% end %> -<% end %> - -<% content_for :header_tags do %> - <%= javascript_tag do %> - $(document).ready(function() { - var key = $('#git_url_list li').first().attr('id'); - var access = access_list[key]; - - $('.git_url_access').html(access.url); - - $('#git_url_list li').on('click', function(){ - var key = $(this).attr('id'); - var access = access_list[key]; - - $('.git_url_access').html(access.url); - - if (access.commiter == true) { - $('#repository_setup').show(); - } else { - $('#repository_setup').hide(); - } - }); - }); - <% end %> -<% end %> diff --git a/app/views/archived_repositories/index.html.slim b/app/views/archived_repositories/index.html.slim deleted file mode 100644 index f50e2c92817..00000000000 --- a/app/views/archived_repositories/index.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -h2 = l(:label_archived_repositories) - -- if @archived_projects.any? - ul - - @archived_projects.each do |project| - - if project.repositories.any? - li - = project.name - ul - - project.repositories.each do |repository| - li - = link_to h(repository.url), { controller: 'archived_repositories', - action: 'show', - id: project, - repository_id: repository.identifier_param } -- else - p.nodata = l(:label_no_data) diff --git a/app/views/archived_repositories/revision.html.erb b/app/views/archived_repositories/revision.html.erb deleted file mode 100644 index d8ccc3e4215..00000000000 --- a/app/views/archived_repositories/revision.html.erb +++ /dev/null @@ -1,101 +0,0 @@ -
- « - <% unless @changeset.previous.nil? -%> - <%= link_to_revision2(@changeset.previous, @repository, :text => l(:label_previous)) %> - <% else -%> - <%= l(:label_previous) %> - <% end -%> -| - <% unless @changeset.next.nil? -%> - <%= link_to_revision2(@changeset.next, @repository, :text => l(:label_next)) %> - <% else -%> - <%= l(:label_next) %> - <% end -%> - »  - - <%= form_tag({:controller => 'archived_repositories', - :action => 'revision', - :id => @project, - :repository_id => @repository.identifier_param, - :rev => nil}, - :method => :get) do %> - <%= text_field_tag 'rev', @rev, :size => 8 %> - <%= submit_tag 'OK', :name => nil %> - <% end %> -
- -

<%= avatar(@changeset.user, :size => "24") %><%= l(:label_revision) %> <%= format_revision(@changeset) %>

- -<% if @changeset.scmid.present? || @changeset.parents.present? || @changeset.children.present? %> - - <% if @changeset.scmid.present? %> - - - - <% end %> - <% if @changeset.parents.present? %> - - - - - <% end %> - <% if @changeset.children.present? %> - - - - - <% end %> -
ID<%= h(@changeset.scmid) %>
<%= l(:label_parent_revision) %> - <%= @changeset.parents.collect{ - |p| link_to_revision2(p, @repository, :text => format_revision(p)) - }.join(", ").html_safe %> -
<%= l(:label_child_revision) %> - <%= @changeset.children.collect{ - |p| link_to_revision2(p, @repository, :text => format_revision(p)) - }.join(", ").html_safe %> -
-<% end %> - -

- -<%= authoring(@changeset.committed_on, @changeset.author) %> - -

- -<%= textilizable @changeset.comments %> - -<% if @changeset.issues.visible.any? || User.current.allowed_to?(:manage_related_issues, @repository.project) %> - <%= render :partial => 'related_issues' %> -<% end %> - -<% if User.current.allowed_to?(:browse_repository, @project) %> -

<%= l(:label_attachment_plural) %>

-
    -
  • <%= l(:label_added) %>
  • -
  • <%= l(:label_modified) %>
  • -
  • <%= l(:label_copied) %>
  • -
  • <%= l(:label_renamed) %>
  • -
  • <%= l(:label_deleted) %>
  • -
- -

<%= link_to(l(:label_view_diff), - :action => 'diff', - :id => @project, - :repository_id => @repository.identifier_param, - :path => "", - :rev => @changeset.identifier) if @changeset.filechanges.any? %>

- -
-<%= render_changeset_changes %> -
-<% end %> - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> -<% end %> - -<% - title = "#{l(:label_revision)} #{format_revision(@changeset)}" - title << " - #{@changeset.comments.truncate(80)}" - html_title(title) - -%> diff --git a/app/views/archived_repositories/revisions.html.erb b/app/views/archived_repositories/revisions.html.erb deleted file mode 100644 index 1ed18b2bbec..00000000000 --- a/app/views/archived_repositories/revisions.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -
-<%= form_tag( - {:controller => 'archived_repositories', :action => 'revision', :id => @project, - :repository_id => @repository.identifier_param}, - :method => :get - ) do %> - <%= l(:label_revision) %>: <%= text_field_tag 'rev', nil, :size => 8 %> - <%= submit_tag 'OK' %> -<% end %> -
- -

<%= l(:label_revision_plural) %>

- -<%= render :partial => 'revisions', - :locals => {:project => @project, - :path => '', - :revisions => @changesets, - :entry => nil } %> - -

<%= pagination_links_full @changeset_pages,@changeset_count %>

- -<% content_for :header_tags do %> - <%= stylesheet_link_tag "scm" %> - <%= auto_discovery_link_tag( - :atom, - params.merge( - {:format => 'atom', :page => nil, :key => User.current.rss_key})) %> -<% end %> - -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> -<% end %> - -<% html_title(l(:label_revision_plural)) -%> diff --git a/app/views/archived_repositories/show.html.erb b/app/views/archived_repositories/show.html.erb deleted file mode 100644 index 619c869a814..00000000000 --- a/app/views/archived_repositories/show.html.erb +++ /dev/null @@ -1,71 +0,0 @@ -<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> - -
- <%= render :partial => 'navigation' %> -
- -

<%= render :partial => 'breadcrumbs', - :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>

- -<% if !@entries.nil? %> - <%= render :partial => 'dir_list' %> -<% end %> - -<%= render_properties(@properties) %> - -<% if @changesets && !@changesets.empty? %> -

<%= l(:label_latest_revision_plural) %>

- <%= render :partial => 'revisions', - :locals => {:project => @project, :path => @path, - :revisions => @changesets, :entry => nil }%> -<% end %> -

-<% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) - sep = '' %> -<% if @repository.supports_all_revisions? && @path.blank? %> - <%= link_to l(:label_view_all_revisions), :action => 'revisions', :id => @project, - :repository_id => @repository.identifier_param %> - <% sep = '|' %> -<% end %> -<% if @repository.supports_directory_revisions? && - ( has_branches || !@path.blank? || !@rev.blank? ) %> - <%= sep %> - <%= link_to l(:label_view_revisions), - :action => 'changes', - :path => to_path_param(@path), - :id => @project, - :repository_id => @repository.identifier_param, - :rev => @rev %> -<% end %> -

-<% if @repository.supports_all_revisions? %> - <% content_for :header_tags do %> - <%= auto_discovery_link_tag( - :atom, params.merge( - {:format => 'atom', :action => 'revisions', - :id => @project, :page => nil, :key => User.current.rss_key})) %> - <% end %> - - <%= call_hook(:view_repositories_show_bottom, { :repository => @repository, :project => @project }) %> - -<% end %> - -<% content_for :sidebar do %> -

<%= l(:label_repository_plural) %>

-
    - <% @repositories.sort.each do |repo| %> -
  • <%= link_to h(repo.name), {:controller => 'archived_repositories', :action => 'show', :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, - :class => 'repository' + (@repository.is_a?(Repository::Xitolite) ? ' git' : '') + (repo == @repository ? ' selected' : '') %> -
  • - <% end %> -
- - <%= render :partial => 'repositories/download_revision', - :locals => { :repository => @repository } %> -<% end %> - -<% content_for :header_tags do %> - <%= stylesheet_link_tag "scm" %> -<% end %> - -<% html_title(l(:label_repository)) -%> diff --git a/app/views/common/_git_hosting_js_headers.html.slim b/app/views/common/_git_hosting_js_headers.html.slim index ddc4248d380..5f10262c609 100644 --- a/app/views/common/_git_hosting_js_headers.html.slim +++ b/app/views/common/_git_hosting_js_headers.html.slim @@ -1,12 +1,3 @@ - content_for :header_tags do - = bootstrap_load_base - = bootstrap_load_module(:alerts) - = bootstrap_load_module(:label) - = bootstrap_load_module(:modals) - = bootstrap_load_module(:tables) - = bootstrap_load_module(:sortable) - = stylesheet_link_tag 'application', plugin: 'redmine_git_hosting' = javascript_include_tag 'application', plugin: 'redmine_git_hosting' - -#modal-box data-label-save="#{l(:button_save)}" data-label-cancel="#{l(:button_cancel)}" data-label-ok="#{l(:button_ok)}" diff --git a/app/views/common/_git_urls.html.slim b/app/views/common/_git_urls.html.slim index dd6f1fcbbbc..8d3b52b92a6 100644 --- a/app/views/common/_git_urls.html.slim +++ b/app/views/common/_git_urls.html.slim @@ -1,15 +1,17 @@ - content_for :header_tags do - = bootstrap_load_module(:tooltip) - = additionals_library_load(:clipboardjs) + = additionals_library_load :clipboardjs = stylesheet_link_tag 'git_urls', plugin: 'redmine_git_hosting' = javascript_include_tag 'git_urls', plugin: 'redmine_git_hosting' javascript: - $(document).ready(function() { setFirstGitUrl('.git_url_list'); setGitUrls('.git_url'); }); + $(function() { + setFirstGitUrl('.git_url_list'); setGitUrls('.git_url'); + $('.clipboard-button').tooltip(); + }) -- repositories = Array.wrap(repository) unless repositories -- if repositories.map(&:available_urls_sorted).reject { |h| h.empty? }.any? +- repositories ||= Array.wrap(repository) +- if repositories.map(&:available_urls_sorted).any? - repositories.sort_by { |r| r.is_default ? 0 : 1 }.each do |repository| - next if repository.available_urls_sorted.empty? - present repository do |p| diff --git a/app/views/dashboards/blocks/_git_urls.html.slim b/app/views/dashboards/blocks/_git_urls.html.slim new file mode 100644 index 00000000000..7509978228f --- /dev/null +++ b/app/views/dashboards/blocks/_git_urls.html.slim @@ -0,0 +1,16 @@ +- if @project.module_enabled?(:repository) && \ + @project.repository.is_a?(Repository::Xitolite) && \ + User.current.allowed_to?(:view_changesets, @project) + .git_hosting + h3 + = @project.repositories.count > 1 ? l(:label_repository_plural) : l(:label_repository) + = render partial: 'common/git_urls', locals: { repositories: @project.gitolite_repos } + - if @project.repositories.count > 1 + .clear-both + p + = link_to l(:label_see_other_repositories), { controller: '/repositories', + action: 'show', + id: @project, + repository_id: @project.repository.identifier_param, + rev: nil, + path: nil } diff --git a/app/views/gitolite_public_keys/_form.html.slim b/app/views/gitolite_public_keys/_form.html.slim index 2d0d7e5d624..7d15cab536c 100644 --- a/app/views/gitolite_public_keys/_form.html.slim +++ b/app/views/gitolite_public_keys/_form.html.slim @@ -2,7 +2,7 @@ = error_messages_for 'gitolite_public_key' = labelled_form_for :gitolite_public_key, GitolitePublicKey.new, - url: { controller: 'gitolite_public_keys', action: 'create', user_id: params[:id], tab: params[:id]&&'keys' }, + url: { controller: 'gitolite_public_keys', action: 'create', user_id: params[:id], tab: params[:id] && 'keys' }, html: { method: :post } do |f| p = f.text_field :title, label: :label_identifier_can_be_arbitrary, required: true, style: 'width: 97%;' @@ -10,7 +10,7 @@ - if can_create_deployment_keys_for_some_project(@user) p = f.select :key_type, - options_for_select([[l(:label_user_key), 0 ],[l(:label_deploy_key), 1 ]],), + options_for_select([[l(:label_user_key), 0], [l(:label_deploy_key), 1]]), { required: true, label: :label_key_type }, { class: 'select_key_type' } #key_type_options style="display: none;" @@ -18,7 +18,7 @@ = f.check_box :delete_when_unused, required: true, label: :label_deployment_credential_delete_when_unused p = f.text_area :key, label: :label_public_key, required: true, - style: "width: 97%; height: 200px; overflow: auto;", + style: 'width: 97%; height: 200px; overflow: auto;', cols: nil, rows: nil em diff --git a/app/views/projects/_git_urls.html.slim b/app/views/projects/_git_urls.html.slim deleted file mode 100644 index b0083396c25..00000000000 --- a/app/views/projects/_git_urls.html.slim +++ /dev/null @@ -1,16 +0,0 @@ -- if project.module_enabled?(:repository) - - if project.repository && project.repository.is_a?(Repository::Xitolite) - - if RedmineGitHosting::Config.show_repositories_url? && User.current.allowed_to?(:view_changesets, project) - .git_hosting.box - h3 - = project.repositories.count > 1 ? l(:label_repository_plural) : l(:label_repository) - = render partial: 'common/git_urls', locals: { repositories: project.gitolite_repos } - - if project.repositories.count > 1 - .clear-both - p - = link_to l(:label_see_other_repositories), { controller: '/repositories', - action: 'show', - id: project, - repository_id: project.repository.identifier_param, - rev: nil, - path: nil } diff --git a/app/views/projects/settings/_repositories.html.slim b/app/views/projects/settings/_repositories.html.slim index 7a1e5bf1f9e..20bc078d499 100644 --- a/app/views/projects/settings/_repositories.html.slim +++ b/app/views/projects/settings/_repositories.html.slim @@ -1,61 +1,64 @@ -- if @project.repositories.any? - table.table.table-hover - thead - tr - th = l(:field_identifier) - th = l(:field_repository_is_default) - th = l(:label_scm) - th = l(:label_repository) - th = l(:label_repository_default_branch) - th = l(:label_repository_enabled_capabilities) - th - tbody - - @project.repositories.sort.each do |repository| - tr - td = repository.identifier.present? ? repository.identifier : '' - td = checked_image repository.is_default? - td = repository.scm_name - td = link_to h(repository.url), - { controller: 'repositories', - action: 'show', - id: @project, - repository_id: repository.identifier_param } - td - - if repository.is_a?(Repository::Xitolite) - span.label.label-info = repository.git_default_branch - td align='center' - - if repository.is_a?(Repository::Xitolite) - - if repository.git_annex_enabled? - = render_feature(repository, :git_annex) - - else - = render_feature(repository, :deployment_credentials) - = render_feature(repository, :post_receive_urls) - = render_feature(repository, :mirrors) - = render_feature(repository, :git_daemon) - = render_feature(repository, :git_http) - = render_feature(repository, :git_notify) - = render_feature(repository, :protected_branch) - = render_feature(repository, :public_repo) +- if User.current.admin? + .contextual + = link_to l(:label_administration), plugin_settings_path(id: 'redmine_git_hosting'), class: 'icon icon-settings' - td.buttons - - if User.current.allowed_to?(:manage_repository, @project) - = link_to l(:label_user_plural), committers_repository_path(repository), - class: 'icon icon-user' +- if User.current.allowed_to? :manage_repository, @project + p = link_to l(:label_repository_new), + new_project_repository_path(@project), + class: 'icon icon-add' - = link_to l(:button_edit), edit_repository_path(repository), - class: 'icon icon-edit' +- if @project.repositories.any? + .autoscroll + table.list + thead + tr + th = l :field_identifier + th = l :field_repository_is_default + th = l :label_scm + th = l :label_repository + th = l :label_repository_default_branch + th = l :label_repository_enabled_capabilities + th + tbody + - @project.repositories.sort.each do |repository| + tr + td = repository.identifier.presence || '' + td = checked_image repository.is_default? + td = repository.scm_name + td = link_to h(repository.url), + { controller: 'repositories', + action: 'show', + id: @project, + repository_id: repository.identifier_param } + td + - if repository.is_a? Repository::Xitolite + span.label.label-info = repository.git_default_branch + td align='center' + - if repository.is_a? Repository::Xitolite + - if repository.git_annex_enabled? + = render_feature repository, :git_annex + - else + = render_feature repository, :deployment_credentials + = render_feature repository, :post_receive_urls + = render_feature repository, :mirrors + = render_feature repository, :git_daemon + = render_feature repository, :git_http + = render_feature repository, :git_notify + = render_feature repository, :protected_branch + = render_feature repository, :public_repo - = link_to l(:button_move), move_repository_git_extras_path(repository), - class: 'icon icon-move' if repository.is_a?(Repository::Xitolite) && repository.movable? + td.buttons + - if User.current.allowed_to? :manage_repository, @project + = link_to l(:label_user_plural), committers_repository_path(repository), class: 'icon icon-user' + = link_to l(:button_edit), edit_repository_path(repository), class: 'icon icon-edit' + - if repository.is_a?(Repository::Xitolite) && repository.movable? + = link_to l(:button_move), move_repository_git_extras_path(repository), class: 'icon icon-move' + = delete_link repository_path(repository) - = delete_link repository_path(repository) + javascript: + $(function() { + $('.icon-git').tooltip(); + }) - else - p.nodata = l(:label_no_data) - -- if User.current.allowed_to?(:manage_repository, @project) - p = link_to l(:label_repository_new), new_project_repository_path(@project), class: 'icon icon-add' - -- content_for :header_tags do - = bootstrap_load_module(:label) - = bootstrap_load_module(:tables) + p.nodata = l :label_no_data diff --git a/app/views/repositories/_edit_bottom.html.slim b/app/views/repositories/_edit_bottom.html.slim index 583742b0fb8..f63f0354e25 100644 --- a/app/views/repositories/_edit_bottom.html.slim +++ b/app/views/repositories/_edit_bottom.html.slim @@ -1,16 +1,4 @@ - if @repository.is_a?(Repository::Xitolite) && !@repository.git_annex_enabled? - - content_for :header_tags do - javascript: - $(document).on('click', 'a.modal-box', function(e){ - e.preventDefault(); - openModalBox(this, 'modal-box'); - }); - - $(document).on('click', 'a.modal-box-close-only', function(e){ - e.preventDefault(); - openModalBox(this, 'modal-box-close-only'); - }); - #repository-tabs ul - if User.current.git_allowed_to?(:view_repository_deployment_credentials, @repository) diff --git a/app/views/repositories/_edit_top.html.slim b/app/views/repositories/_edit_top.html.slim index 8bfbb25dc69..6651b7d0726 100644 --- a/app/views/repositories/_edit_top.html.slim +++ b/app/views/repositories/_edit_top.html.slim @@ -8,6 +8,6 @@ ' = link_to l(:label_sort_urls), sort_urls_repository_git_extras_path(@repository), - class: 'modal-box-close-only' + remote: true = render 'common/git_urls', repository: @repository diff --git a/app/views/repositories/_git_hosting_navigation.html.slim b/app/views/repositories/_git_hosting_navigation.html.slim index 0844e3be194..c2578605b41 100644 --- a/app/views/repositories/_git_hosting_navigation.html.slim +++ b/app/views/repositories/_git_hosting_navigation.html.slim @@ -1 +1,2 @@ -= watcher_link(@repository, User.current) +- if User.current.allowed_to? :add_repository_xitolite_watchers, @project + = watcher_link @repository, User.current diff --git a/app/views/repositories/_git_hosting_sidebar.html.slim b/app/views/repositories/_git_hosting_sidebar.html.slim index 2ce877a0cbb..084e47003a0 100644 --- a/app/views/repositories/_git_hosting_sidebar.html.slim +++ b/app/views/repositories/_git_hosting_sidebar.html.slim @@ -1,14 +1,17 @@ ul.repository.git - @repositories.sort.each do |repo| - - li_class = "#{'repository git' if repo.is_a?(Repository::Xitolite)}" - li class="#{li_class}" - = link_to_repository(repo, @repository) - - if User.current.allowed_to?(:manage_repository, @project) + li class="#{'repository git' if repo.is_a? Repository::Xitolite}" + = link_to_repository repo, @repository + - if User.current.allowed_to? :manage_repository, @project ' = link_to "(#{l(:label_settings)})", edit_repository_path(repo) -- if @repository.try(:watchers) && (User.current.allowed_to?(:add_repository_xitolite_watchers, @project) || (@repository.watchers.present? && User.current.allowed_to?(:view_repository_xitolite_watchers, @project))) - #watchers= render 'watchers/watchers', watched: @repository +- if @repository.try(:watchers) && \ + (User.current.allowed_to?(:add_repository_xitolite_watchers, @project) || \ + (@repository.watchers.present? && User.current.allowed_to?(:view_repository_xitolite_watchers, @project))) + + #watchers + = render 'watchers/watchers', watched: @repository javascript: $(document).ready(function() { $('#sidebar p').remove(); }); diff --git a/app/views/repositories/_show_top.html.slim b/app/views/repositories/_show_top.html.slim index 2cf70c757a1..a8e28291063 100644 --- a/app/views/repositories/_show_top.html.slim +++ b/app/views/repositories/_show_top.html.slim @@ -1,6 +1,5 @@ -- if @repository.is_a?(Repository::Xitolite) +- if @repository.is_a? Repository::Xitolite - content_for :header_tags do - = bootstrap_load_base = stylesheet_link_tag 'application', plugin: 'redmine_git_hosting' = stylesheet_link_tag 'markdown', plugin: 'redmine_git_hosting' @@ -8,8 +7,7 @@ .container .row .col-md-8 style='vertical-align: middle;' - - if RedmineGitHosting::Config.show_repositories_url? - = render 'common/git_urls', repository: @repository + = render 'common/git_urls', repository: @repository .col-md-4 style='text-align: right; vertical-align: middle;' - if RedmineGitHosting::Config.download_revision_enabled? = render 'repositories/download_revision', repository: @repository diff --git a/app/views/repositories/_xitolite_options.html.slim b/app/views/repositories/_xitolite_options.html.slim index 74d9c88f8a5..16aa0c012bc 100644 --- a/app/views/repositories/_xitolite_options.html.slim +++ b/app/views/repositories/_xitolite_options.html.slim @@ -1,4 +1,4 @@ -- if repository.is_a?(Repository::Xitolite) +- if repository.is_a? Repository::Xitolite = form_for repository.extra, url: repository_git_extras_path(repository), html: { method: :put, remote: true } do |f| .box.tabular .container @@ -62,23 +62,23 @@ span.label.label-info = repository.git_default_branch p - label= l(:label_mirroring_keys_installed) - = image_tag (RedmineGitHosting::Config.mirroring_keys_installed? ? 'true.png' : 'exclamation.png') + label = l :label_mirroring_keys_installed + = image_tag(RedmineGitHosting::Config.mirroring_keys_installed? ? 'true.png' : 'exclamation.png') p - label = l(:label_repository_exists_in_gitolite) - = image_tag (repository.exists_in_gitolite? ? 'true.png' : 'exclamation.png') + label = l :label_repository_exists_in_gitolite + = image_tag(repository.exists_in_gitolite? ? 'true.png' : 'exclamation.png') p - if repository.empty_in_gitolite? - label = l(:label_empty_repository) - = image_tag('true.png') + label = l :label_empty_repository + = image_tag 'true.png' - else - label = l(:label_git_objects_count) + label = l :label_git_objects_count = repository.git_objects_count p - label= l(:label_browse_repository) + label = l :label_browse_repository = link_to h(repository.url), { controller: 'repositories', action: 'show', id: @project, repository_id: repository.identifier_param } diff --git a/app/views/repositories/edit.html.slim b/app/views/repositories/edit.html.slim index 68b9ae6b03a..0f3c6e026bd 100644 --- a/app/views/repositories/edit.html.slim +++ b/app/views/repositories/edit.html.slim @@ -10,21 +10,15 @@ h2 = Additionals::LIST_SEPARATOR = @repository.redmine_name -.container - .row - .col-md-12 - = call_hook(:view_repository_edit_top, repository: @repository, project: @project) +.splitcontent + .splitcontentleft + = call_hook(:view_repository_edit_top, repository: @repository, project: @project) -.container - .row - .col-md-6 - = labelled_form_for :repository, @repository, url: repository_path(@repository), html: { method: :put, id: 'repository-form' } do |f| - = render partial: 'form', locals: { f: f } + = labelled_form_for :repository, @repository, url: repository_path(@repository), html: { method: :put, id: 'repository-form' } do |f| + = render partial: 'form', locals: { f: f } - .col-md-6#xitolite-options style='vertical-align: top;' + .splitcontentright + #xitolite-options style='vertical-align: top;' = render 'xitolite_options', repository: @repository -.container - .row - .col-md-12 - = call_hook(:view_repository_edit_bottom, repository: @repository, project: @project) += call_hook(:view_repository_edit_bottom, repository: @repository, project: @project) diff --git a/app/views/repositories/git_instructions.html.slim b/app/views/repositories/git_instructions.html.slim index 253009101b2..af80696cae9 100644 --- a/app/views/repositories/git_instructions.html.slim +++ b/app/views/repositories/git_instructions.html.slim @@ -1,4 +1,4 @@ -#flash_warning.flash.warning = l(:notice_empty_repository) +#flash_warning.flash.warning = l :notice_empty_repository - if @repository.urls_are_viewable? - content_for :header_tags do @@ -12,63 +12,73 @@ .col-md-4 style='text-align: right; vertical-align: middle;' .box - - if User.current.allowed_to?(:view_changesets, @project) - h3 = l(:label_help_git_setup) + ' :' + - if User.current.allowed_to? :view_changesets, @project + h3 + = l :label_help_git_setup + | : pre code.shell.syntaxhl - | #{link_to l(:label_download_and_install_git), 'https://git-scm.com/download', target: 'external' } + = link_to l(:label_download_and_install_git), 'https://git-scm.com/download', class: 'external' br - | git config --global user.name "#{User.current.name(:firstname_lastname)}" + == render_shell_text "git config --global user.name \"#{User.current.name(:firstname_lastname)}\"" br - | git config --global user.email #{User.current.mail ? User.current.mail : "mail@example.com"} - - if !User.current.anonymous? && User.current.gitolite_public_keys.length == 0 + == render_shell_text "git config --global user.email #{User.current.mail || 'mail@example.com'}" + - if !User.current.anonymous? && User.current.gitolite_public_keys.empty? br - | #{link_to "Upload SSH Public Key", public_keys_path} + = link_to 'Upload SSH Public Key', public_keys_path - - if User.current.allowed_to?(:commit_access, @project) + - if User.current.allowed_to? :commit_access, @project #repository_setup - h3 = l(:label_help_repository_setup_new) + ' :' + h3 + = l :label_help_repository_setup_new + | : pre code.shell.syntaxhl - | mkdir #{@repository.redmine_name} + == render_shell_text "mkdir #{@repository.redmine_name}" br - | cd #{@repository.redmine_name} + == render_shell_text "cd #{@repository.redmine_name}" br - | git init + == render_shell_text 'git init' br - | touch readme.txt + == render_shell_text 'touch readme.txt' br - | git add readme.txt + == render_shell_text 'git add readme.txt' br - | git commit -m 'Initializing #{@repository.redmine_name} repository' + == render_shell_text "git commit -m 'Initializing #{@repository.redmine_name} repository'" br - | git remote add origin + ' git remote add origin + span.git_url_access br - | git push -u origin master + == render_shell_text 'git push -u origin master' - h3 = l(:label_help_repository_setup_existing) + ' :' + h3 + = l :label_help_repository_setup_existing + | : pre code.shell.syntaxhl - | cd existing_git_repo + == render_shell_text 'cd existing_git_rep' br - | git remote add origin + ' git remote add origin + span.git_url_access br - | git push -u origin master + == render_shell_text 'git push -u origin master' - h3 = l(:label_help_repository_clone) + ' :' + h3 + = l :label_help_repository_clone + | : pre code.shell.syntaxhl - | git clone + ' git clone + span.git_url_access - else - = l(:label_help_no_repo_rights) + = l :label_help_no_repo_rights - content_for :sidebar do - h3 = l(:label_repository_plural) + h3 = l :label_repository_plural ul.repository.git - @repositories.sort.each do |repo| - - li_class = "#{'repository git' if repo.is_a?(Repository::Xitolite)}" - li class="#{li_class}" + li class="#{'repository git' if repo.is_a?(Repository::Xitolite)}" = link_to_repository(repo, @repository) - if User.current.allowed_to?(:manage_repository, @project) ' diff --git a/app/views/repositories/stats.html.slim b/app/views/repositories/stats.html.slim index 9493a17dfd3..3c6a344d569 100644 --- a/app/views/repositories/stats.html.slim +++ b/app/views/repositories/stats.html.slim @@ -1,4 +1,4 @@ -h2 = l(:label_statistics) +h2 = l :label_statistics #statistics-tabs ul @@ -25,13 +25,12 @@ p = link_to l(:button_back), action: 'show', id: @project - html_title(l(:label_repository), l(:label_statistics)) - content_for :header_tags do - = bootstrap_load_base = javascript_include_tag('highcharts/highcharts', plugin: 'redmine_git_hosting') = javascript_include_tag('highcharts/modules/drilldown', plugin: 'redmine_git_hosting') = stylesheet_link_tag 'application', plugin: 'redmine_git_hosting' = javascript_include_tag 'set_highcharts', plugin: 'redmine_git_hosting' -- charts = @author_charts.map { |chart| 'createZoomableAreaChart(' + chart + ');' } +- charts = @author_charts.map { |chart| "createZoomableAreaChart(#{chart});" } javascript: $(document).ready(function() { createAreaChart(chart_commits_per_month); diff --git a/app/views/repository_deployment_credentials/edit.html.slim b/app/views/repository_deployment_credentials/_edit_modal.html.slim similarity index 76% rename from app/views/repository_deployment_credentials/edit.html.slim rename to app/views/repository_deployment_credentials/_edit_modal.html.slim index 94d76f0e120..af31e9fb4ee 100644 --- a/app/views/repository_deployment_credentials/edit.html.slim +++ b/app/views/repository_deployment_credentials/_edit_modal.html.slim @@ -1,3 +1,5 @@ +h3.title = l :label_deployment_credential_edit + = labelled_form_for :repository_deployment_credential, @credential, url: repository_deployment_credential_path(@repository, @credential), authenticity_token: form_authenticity_token, @@ -8,3 +10,8 @@ .box p = f.select :perm, options_for_select(RepositoryDeploymentCredential::VALID_PERMS, @credential.perm), required: true p = f.check_box :active + + .buttons + = submit_tag l :button_save + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_deployment_credentials/_new_modal.html.slim b/app/views/repository_deployment_credentials/_new_modal.html.slim new file mode 100644 index 00000000000..4497b31da86 --- /dev/null +++ b/app/views/repository_deployment_credentials/_new_modal.html.slim @@ -0,0 +1,25 @@ +h3.title = l(:label_deployment_credential_add) + += labelled_form_for :repository_deployment_credential, @credential, + url: repository_deployment_credentials_path(@repository), + html: { method: :post, class: 'tabular', remote: true } do |f| + + .flash-messages = error_messages_for 'credential' + + .box + - if @user_keys.present? || @other_keys.present? + p = f.select :gitolite_public_key_id, + build_list_of_keys(@user_keys, @other_keys, @disabled_keys), + required: true, + label: :label_deployment_credential_select_deploy_key + p = f.select :perm, + options_for_select(RepositoryDeploymentCredential::VALID_PERMS, RepositoryDeploymentCredential::DEFAULT_PERM), + required: true, + label: :label_permissions + - else + = link_to l(:label_deployment_credential_create_key_first), public_keys_path + + .buttons + = submit_tag l(:button_add) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_deployment_credentials/create.js.erb b/app/views/repository_deployment_credentials/create.js.erb deleted file mode 100644 index 779c010b07b..00000000000 --- a/app/views/repository_deployment_credentials/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_deployment_credentials/new') %> diff --git a/app/views/repository_deployment_credentials/edit.js.erb b/app/views/repository_deployment_credentials/edit.js.erb new file mode 100644 index 00000000000..a0d04262c5d --- /dev/null +++ b/app/views/repository_deployment_credentials/edit.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_deployment_credentials/edit_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_deployment_credentials/index.html.slim b/app/views/repository_deployment_credentials/index.html.slim index 880dcc0229b..ccceccb7dfb 100644 --- a/app/views/repository_deployment_credentials/index.html.slim +++ b/app/views/repository_deployment_credentials/index.html.slim @@ -1,15 +1,15 @@ div - if User.current.git_allowed_to?(:create_repository_deployment_credentials, @repository) .contextual - - css_class = (@user_keys.present? || @other_keys.present?) ? 'modal-box' : 'modal-box-close-only' = link_to l(:label_deployment_credential_add), new_repository_deployment_credential_path(@repository), - class: "icon icon-add #{css_class}" + remote: true, + class: 'icon icon-add' h3 = l(:label_deployment_credentials) - if @repository_deployment_credentials.any? - table.table.table-hover + table.list thead tr th = l(:label_deployment_credential_owner) @@ -17,12 +17,12 @@ div th = l(:label_deployment_credential_public_key_file) th = l(:label_permissions) th = l(:label_deployment_credential_honored) - th = l(:label_deployment_credential_active) + th = l(:field_active) th tbody - - @repository_deployment_credentials.sort_by {|x| [x.user.login, x.gitolite_public_key.title]}.each do |credential| + - @repository_deployment_credentials.sort_by { |x| [x.user.login, x.gitolite_public_key.title] }.each do |credential| tr - td= credential.user.login + td = credential.user.login td - if credential.user == User.current = link_to credential.gitolite_public_key.title, public_keys_path @@ -33,12 +33,22 @@ div td = credential.gitolite_public_key.gitolite_path td = credential.perm - td = checked_image_with_exclamation credential.honored? - td = checked_image_with_exclamation credential.active? + td.tick = checked_image_with_exclamation credential.honored? + td.tick = checked_image_with_exclamation credential.active? td.buttons - - if User.current.git_allowed_to?(:edit_repository_deployment_credentials, @repository) && (User.current.admin? || User.current == credential.user) - = link_to l(:button_edit), edit_repository_deployment_credential_path(@repository, credential), class: 'icon icon-edit modal-box' - = link_to l(:button_delete), repository_deployment_credential_path(@repository, credential), remote: true, method: :delete, data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del' + - if User.current.git_allowed_to?(:edit_repository_deployment_credentials, @repository) && \ + (User.current.admin? || User.current == credential.user) + = link_to l(:button_edit), + edit_repository_deployment_credential_path(@repository, credential), + remote: true, + class: 'icon icon-edit' + = link_to l(:button_delete), + repository_deployment_credential_path(@repository, credential), + remote: true, + method: :delete, + data: { confirm: l(:text_are_you_sure) }, + class: 'icon icon-del' + - else - p.nodata = l(:label_no_data) + p.nodata = l :label_no_data diff --git a/app/views/repository_deployment_credentials/new.html.slim b/app/views/repository_deployment_credentials/new.html.slim deleted file mode 100644 index 4b27def9f57..00000000000 --- a/app/views/repository_deployment_credentials/new.html.slim +++ /dev/null @@ -1,13 +0,0 @@ -= labelled_form_for :repository_deployment_credential, @credential, - url: repository_deployment_credentials_path(@repository), - authenticity_token: form_authenticity_token, - html: { method: :post, class: 'tabular', remote: true } do |f| - - .flash-messages= error_messages_for 'credential' - - .box - - if @user_keys.present? || @other_keys.present? - p = f.select :gitolite_public_key_id, build_list_of_keys(@user_keys, @other_keys, @disabled_keys), required: true, label: :label_deployment_credential_select_deploy_key - p = f.select :perm, options_for_select(RepositoryDeploymentCredential::VALID_PERMS, RepositoryDeploymentCredential::DEFAULT_PERM), required: true, label: :label_permissions - - else - = link_to l(:label_deployment_credential_create_key_first), public_keys_path diff --git a/app/views/repository_deployment_credentials/new.js.erb b/app/views/repository_deployment_credentials/new.js.erb new file mode 100644 index 00000000000..e92cc58faf0 --- /dev/null +++ b/app/views/repository_deployment_credentials/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_deployment_credentials/new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_deployment_credentials/update.js.erb b/app/views/repository_deployment_credentials/update.js.erb deleted file mode 100644 index f128580686b..00000000000 --- a/app/views/repository_deployment_credentials/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_deployment_credentials/edit') %> diff --git a/app/views/repository_git_config_keys/_config_keys.html.slim b/app/views/repository_git_config_keys/_config_keys.html.slim index b20fb6f63a9..9b0a56e78b1 100644 --- a/app/views/repository_git_config_keys/_config_keys.html.slim +++ b/app/views/repository_git_config_keys/_config_keys.html.slim @@ -1,9 +1,9 @@ - if git_config_keys.any? - table.table.table-hover + table.list thead tr - th = l(:label_key) - th = l(:field_value) + th = l :label_key + th = l :field_value th tbody - git_config_keys.each do |git_config_key| @@ -16,7 +16,7 @@ - if User.current.git_allowed_to?(:edit_repository_git_config_keys, @repository) = link_to l(:button_edit), edit_repository_git_config_key_path(@repository, git_config_key), - class: 'icon icon-edit modal-box' + class: 'icon icon-edit' = link_to l(:button_delete), repository_git_config_key_path(@repository, git_config_key), remote: true, @@ -25,4 +25,4 @@ class: 'icon icon-del' - else - p.nodata = l(:label_no_data) + p.nodata = l :label_no_data diff --git a/app/views/repository_git_config_keys/edit.html.slim b/app/views/repository_git_config_keys/_edit_modal.html.slim similarity index 69% rename from app/views/repository_git_config_keys/edit.html.slim rename to app/views/repository_git_config_keys/_edit_modal.html.slim index b54bdf35ed7..4f70e4c2f2c 100644 --- a/app/views/repository_git_config_keys/edit.html.slim +++ b/app/views/repository_git_config_keys/_edit_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_git_config_keys + = labelled_form_for :repository_git_config_key, @git_config_key, url: repository_git_config_key_path(@repository, @git_config_key), authenticity_token: form_authenticity_token, html: { method: :put, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_save) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_git_config_keys/_form.html.slim b/app/views/repository_git_config_keys/_form.html.slim index aa3b366417e..c285fbc34cf 100644 --- a/app/views/repository_git_config_keys/_form.html.slim +++ b/app/views/repository_git_config_keys/_form.html.slim @@ -5,5 +5,5 @@ options_for_select(git_config_key_options, @git_config_key.type), { required: @git_config_key.new_record?, prompt: 'Select a key type' }, { disabled: !@git_config_key.new_record? } - p = f.text_field :key, required: true, size: 65, label: :label_key + p = f.text_field :key, required: true, size: 65, label: :label_key p = f.text_field :value, required: true, size: 65 diff --git a/app/views/repository_git_config_keys/new.html.slim b/app/views/repository_git_config_keys/_new_modal.html.slim similarity index 69% rename from app/views/repository_git_config_keys/new.html.slim rename to app/views/repository_git_config_keys/_new_modal.html.slim index 696015367c1..d093ebb1408 100644 --- a/app/views/repository_git_config_keys/new.html.slim +++ b/app/views/repository_git_config_keys/_new_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l(:label_git_config_keys) + = labelled_form_for :repository_git_config_key, @git_config_key, url: repository_git_config_keys_path(@repository), authenticity_token: form_authenticity_token, html: { method: :post, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_add) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_git_config_keys/create.js.erb b/app/views/repository_git_config_keys/create.js.erb deleted file mode 100644 index 4ae49153a0e..00000000000 --- a/app/views/repository_git_config_keys/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_git_config_keys/new') %> diff --git a/app/views/repository_git_config_keys/edit.js.erb b/app/views/repository_git_config_keys/edit.js.erb new file mode 100644 index 00000000000..e7fe48059eb --- /dev/null +++ b/app/views/repository_git_config_keys/edit.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_git_config_keys/edit_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_git_config_keys/index.html.slim b/app/views/repository_git_config_keys/index.html.slim index 12f24a16eca..dd32bddd829 100644 --- a/app/views/repository_git_config_keys/index.html.slim +++ b/app/views/repository_git_config_keys/index.html.slim @@ -3,27 +3,30 @@ div .contextual = link_to l(:label_git_config_key_add), new_repository_git_config_key_path(@repository, type: 'git_config'), - class: 'icon icon-add modal-box' + remote: true, + class: 'icon icon-add' h3 = l(:label_git_config_keys) + ' = link_to "(#{l(:label_gitolite_documentation)})", 'https://gitolite.com/gitolite/git-config.html', - target: '_blank' + class: 'external' = render 'config_keys', git_config_keys: @repository_git_config_keys - - if User.current.git_allowed_to?(:create_repository_git_config_keys, @repository) .contextual = link_to l(:label_git_option_key_add), new_repository_git_config_key_path(@repository, type: 'git_option'), - class: 'icon icon-add modal-box' + remote: true, + class: 'icon icon-add' h3 = l(:label_git_option_keys) + ' = link_to "(#{l(:label_gitolite_documentation)})", 'https://gitolite.com/gitolite/options.html', - target: '_blank' + class: 'external' = render 'config_keys', git_config_keys: @repository_git_option_keys diff --git a/app/views/repository_git_config_keys/new.js.erb b/app/views/repository_git_config_keys/new.js.erb new file mode 100644 index 00000000000..d1f0d5c1d25 --- /dev/null +++ b/app/views/repository_git_config_keys/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_git_config_keys/new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_git_config_keys/update.js.erb b/app/views/repository_git_config_keys/update.js.erb deleted file mode 100644 index 0a5ec5b9bf4..00000000000 --- a/app/views/repository_git_config_keys/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_git_config_keys/edit') %> diff --git a/app/views/repository_git_extras/sort_urls.html.slim b/app/views/repository_git_extras/_sort_urls_modal.html.slim similarity index 64% rename from app/views/repository_git_extras/sort_urls.html.slim rename to app/views/repository_git_extras/_sort_urls_modal.html.slim index 739dee3562f..9af01764495 100644 --- a/app/views/repository_git_extras/sort_urls.html.slim +++ b/app/views/repository_git_extras/_sort_urls_modal.html.slim @@ -1,11 +1,10 @@ -#sortable-url-messages - ul#sortable-url.list-unstyled data-remote="true" data-update-url="#{sort_urls_repository_git_extras_path(@repository)}" - - @repository.available_urls_sorted.keys.each do |url_type| + - @repository.available_urls_sorted.each_key do |url_type| li.url_type.draggable id="repository_git_extra_#{url_type}" - = icon_for_url_type(url_type) + = icon_for_url_type url_type ' - span = label_for_url_type(url_type) + span + = label_for_url_type url_type javascript: $(document).ready(function() { setSortableElement('#sortable-url', '#sortable-url'); }); diff --git a/app/views/repository_git_extras/move.html.slim b/app/views/repository_git_extras/move.html.slim index 329e2596233..a5c9aa8854c 100644 --- a/app/views/repository_git_extras/move.html.slim +++ b/app/views/repository_git_extras/move.html.slim @@ -1,4 +1,4 @@ -h2 = l(:label_move_repository, repo_name: @repository.gitolite_repository_name) +h2 = l :label_move_repository, repo_name: @repository.gitolite_repository_name .box = labelled_form_for :repository_mover, @move_repository_form, diff --git a/app/views/repository_git_extras/sort_urls.js.erb b/app/views/repository_git_extras/sort_urls.js.erb index 829775fe64d..3c253748117 100644 --- a/app/views/repository_git_extras/sort_urls.js.erb +++ b/app/views/repository_git_extras/sort_urls.js.erb @@ -1 +1,2 @@ -$('#sortable-url-messages').html("<%= escape_javascript render_flash_messages %>"); +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_git_extras/sort_urls_modal') %>'); +showModal('ajax-modal', '400px'); diff --git a/app/views/repository_mirrors/edit.html.slim b/app/views/repository_mirrors/_edit_modal.html.slim similarity index 68% rename from app/views/repository_mirrors/edit.html.slim rename to app/views/repository_mirrors/_edit_modal.html.slim index a8f13dc110d..d0dae84004d 100644 --- a/app/views/repository_mirrors/edit.html.slim +++ b/app/views/repository_mirrors/_edit_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_mirror_edit + = labelled_form_for :repository_mirror, @mirror, url: repository_mirror_path(@repository, @mirror), authenticity_token: form_authenticity_token, html: { method: :put, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_save) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_mirrors/_form.html.slim b/app/views/repository_mirrors/_form.html.slim index 4ebcf548629..e20f5f7c675 100644 --- a/app/views/repository_mirrors/_form.html.slim +++ b/app/views/repository_mirrors/_form.html.slim @@ -4,7 +4,8 @@ p = f.text_field :url, required: true, size: 65 em p - = l(:label_mirror_url_accepted_format) + ' :' + = l :label_mirror_url_accepted_format + ' : br | ssh://git@redmine.example.org/project1/project2/project3/project4.git br @@ -14,9 +15,9 @@ p = f.select :push_mode, options_for_select(mirrors_options, @mirror.push_mode), { label: :label_mirror_push_mode }, - onchange: "push_mode_change(this); return false;" + onchange: 'push_mode_change(this); return false;' - #ref_spec_options style="#{@mirror.mirror_mode? ? 'display: none;' : ''}" + #ref_spec_options style="#{'display: none;' if @mirror.mirror_mode?}" p = f.check_box :include_all_branches, label: :label_mirror_include_all_branches p = f.check_box :include_all_tags, label: :label_mirror_include_all_tags p = f.text_field :explicit_refspec, label: :label_mirror_explicit_refspec, size: 65 diff --git a/app/views/repository_mirrors/new.html.slim b/app/views/repository_mirrors/_new_modal.html.slim similarity index 68% rename from app/views/repository_mirrors/new.html.slim rename to app/views/repository_mirrors/_new_modal.html.slim index c8a823f6902..e7cd6b90937 100644 --- a/app/views/repository_mirrors/new.html.slim +++ b/app/views/repository_mirrors/_new_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_mirror_add + = labelled_form_for :repository_mirror, @mirror, url: repository_mirrors_path(@repository), authenticity_token: form_authenticity_token, html: { method: :post, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_add) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_mirrors/_push_modal.html.slim b/app/views/repository_mirrors/_push_modal.html.slim new file mode 100644 index 00000000000..dc8e1154aad --- /dev/null +++ b/app/views/repository_mirrors/_push_modal.html.slim @@ -0,0 +1,9 @@ +p style='white-space: nowrap;' + = render_push_state @mirror, @push_failed + +strong + = l :label_mirror_push_output + ' : + +pre class="mirror-push-#{'error' if @push_failed}" + = @shellout diff --git a/app/views/repository_mirrors/create.js.erb b/app/views/repository_mirrors/create.js.erb deleted file mode 100644 index bd5735903ad..00000000000 --- a/app/views/repository_mirrors/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_mirrors/new') %> diff --git a/app/views/repository_mirrors/edit.js.erb b/app/views/repository_mirrors/edit.js.erb new file mode 100644 index 00000000000..ef141e100bc --- /dev/null +++ b/app/views/repository_mirrors/edit.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_mirrors/edit_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_mirrors/index.html.slim b/app/views/repository_mirrors/index.html.slim index 7f1174d0541..a5333da841d 100644 --- a/app/views/repository_mirrors/index.html.slim +++ b/app/views/repository_mirrors/index.html.slim @@ -1,34 +1,44 @@ div - - if User.current.git_allowed_to?(:create_repository_mirrors, @repository) - .contextual= link_to l(:label_mirror_add), new_repository_mirror_path(@repository), class: 'icon icon-add modal-box' + - if User.current.git_allowed_to? :create_repository_mirrors, @repository + .contextual + = link_to l(:label_mirror_add), + new_repository_mirror_path(@repository), + remote: true, + class: 'icon icon-add' - h3 = l(:label_repository_mirrors) + h3 = l :label_repository_mirrors - if @repository_mirrors.any? - table.table.table-hover + table.list thead tr - th = l(:field_url) - th = l(:label_mirror_refspec) - th = l(:label_mode) - th = l(:label_enabled) + th = l :field_url + th = l :label_mirror_refspec + th = l :label_mode + th = l :field_active th tbody - @repository_mirrors.each do |mirror| tr - td = mirror.url - td = refspec(mirror, 64).html_safe - td = mirror_mode(mirror).html_safe - td = checked_image_with_exclamation mirror.active? + td + = mirror.url + + td + = refspec mirror, 64 + + td + = mirror_mode mirror + + td.tick + = checked_image_with_exclamation mirror.active? td.buttons - if User.current.git_allowed_to?(:push_repository_mirrors, @repository) = link_to font_awesome_icon('fas_rocket', post_text: l(:label_mirror_push), class: 'fa-lg'), - push_repository_mirror_path(@repository, mirror), - class: 'modal-box-close-only' + push_repository_mirror_path(@repository, mirror), remote: true - if User.current.git_allowed_to?(:edit_repository_mirrors, @repository) - = link_to l(:button_edit), edit_repository_mirror_path(@repository, mirror), class: 'icon icon-edit modal-box' + = link_to l(:button_edit), edit_repository_mirror_path(@repository, mirror), remote: true, class: 'icon icon-edit' = link_to l(:button_delete), repository_mirror_path(@repository, mirror), remote: true, @@ -37,15 +47,17 @@ div class: 'icon icon-del' - else - p.nodata = l(:label_no_data) + p.nodata = l :label_no_data .git_hosting_spacer div style='margin: 2px 3px; width: 99%;' div - = clipboardjs_button_for('mirror_pubkey') + = clipboardjs_button_for 'mirror_pubkey' + span style='margin-left: 10px;' - = l(:label_mirror_help) + ' :' + = l :label_mirror_help + ' : .git_hosting_spacer diff --git a/app/views/repository_mirrors/new.js.erb b/app/views/repository_mirrors/new.js.erb new file mode 100644 index 00000000000..f2222a66002 --- /dev/null +++ b/app/views/repository_mirrors/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_mirrors/new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_mirrors/push.html.slim b/app/views/repository_mirrors/push.html.slim deleted file mode 100644 index 029bdf5e314..00000000000 --- a/app/views/repository_mirrors/push.html.slim +++ /dev/null @@ -1,8 +0,0 @@ -p style='white-space: nowrap;' - = render_push_state(@mirror, @push_failed) - -span - b = l(:label_mirror_push_output) + ' :' - -pre class="mirror-push-#{@push_failed == true ? 'error' : ''}" } - = @shellout diff --git a/app/views/repository_mirrors/push.js.erb b/app/views/repository_mirrors/push.js.erb new file mode 100644 index 00000000000..bca1dd2f72b --- /dev/null +++ b/app/views/repository_mirrors/push.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_mirrors/push_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_mirrors/update.js.erb b/app/views/repository_mirrors/update.js.erb deleted file mode 100644 index f96945254c3..00000000000 --- a/app/views/repository_mirrors/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_mirrors/edit') %> diff --git a/app/views/repository_post_receive_urls/edit.html.slim b/app/views/repository_post_receive_urls/_edit_modal.html.slim similarity index 69% rename from app/views/repository_post_receive_urls/edit.html.slim rename to app/views/repository_post_receive_urls/_edit_modal.html.slim index 5fa3ad94966..f202d19b802 100644 --- a/app/views/repository_post_receive_urls/edit.html.slim +++ b/app/views/repository_post_receive_urls/_edit_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_post_receive_url_edit + = labelled_form_for :repository_post_receive_url, @post_receive_url, url: repository_post_receive_url_path(@repository, @post_receive_url), authenticity_token: form_authenticity_token, html: { method: :put, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_save) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_post_receive_urls/_form.html.slim b/app/views/repository_post_receive_urls/_form.html.slim index da19da5b251..8d2e1b7f35b 100644 --- a/app/views/repository_post_receive_urls/_form.html.slim +++ b/app/views/repository_post_receive_urls/_form.html.slim @@ -1,22 +1,19 @@ .flash-messages = error_messages_for 'post_receive_url' .box - p = f.text_field :url, required: true, size: 65 - em - p - = l(:label_mirror_url_accepted_format) + ' :' - br - | http://example.com - br - | https://example.com + p = f.url_field :url, + size: 65, + placeholder: 'https://example.com', + required: true p = f.check_box :active p = f.select :mode, [['Github-style POST', :github], - ['Empty GET request', :get]], + ['Empty POST request', :post], + ['Empty GET request', :get]], {}, - onchange: "post_mode_change(this); return false;" + onchange: 'post_mode_change(this); return false;' #payload_options style="#{@post_receive_url.github_mode? ? '' : 'display: none;'}" p = f.check_box :split_payloads diff --git a/app/views/repository_post_receive_urls/new.html.slim b/app/views/repository_post_receive_urls/_new_modal.html.slim similarity index 68% rename from app/views/repository_post_receive_urls/new.html.slim rename to app/views/repository_post_receive_urls/_new_modal.html.slim index 1dca07b40c4..bf5e3d3933f 100644 --- a/app/views/repository_post_receive_urls/new.html.slim +++ b/app/views/repository_post_receive_urls/_new_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_post_receive_url_add + = labelled_form_for :repository_post_receive_url, @post_receive_url, url: repository_post_receive_urls_path(@repository), authenticity_token: form_authenticity_token, html: { method: :post, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_add) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_post_receive_urls/create.js.erb b/app/views/repository_post_receive_urls/create.js.erb deleted file mode 100644 index c3e9d8d6a26..00000000000 --- a/app/views/repository_post_receive_urls/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_post_receive_urls/new') %> diff --git a/app/views/repository_post_receive_urls/edit.js.erb b/app/views/repository_post_receive_urls/edit.js.erb new file mode 100644 index 00000000000..993747cd2d0 --- /dev/null +++ b/app/views/repository_post_receive_urls/edit.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_post_receive_urls/edit_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_post_receive_urls/index.html.slim b/app/views/repository_post_receive_urls/index.html.slim index 7b855d83308..901907305b1 100644 --- a/app/views/repository_post_receive_urls/index.html.slim +++ b/app/views/repository_post_receive_urls/index.html.slim @@ -1,35 +1,54 @@ div - - if User.current.git_allowed_to?(:create_repository_post_receive_urls, @repository) + - if User.current.git_allowed_to? :create_repository_post_receive_urls, @repository .contextual - = link_to l(:label_post_receive_url_add), new_repository_post_receive_url_path(@repository), class: 'icon icon-add modal-box' + = link_to l(:label_post_receive_url_add), + new_repository_post_receive_url_path(@repository), + remote: true, class: 'icon icon-add' h3 = l(:label_post_receive_urls) - if @repository_post_receive_urls.any? - table.table.table-hover + table.list thead tr - th = l(:field_url) - th = l(:label_mode) - th = l(:label_enabled) - th = l(:label_use_triggers) - th = l(:label_triggers) + th = l :field_url + th = l :label_mode + th = l :field_active + th = l :label_use_triggers + th = l :label_triggers th tbody - @repository_post_receive_urls.each do |post_receive_url| tr - td = post_receive_url.url - td = post_receive_mode(post_receive_url).html_safe - td = checked_image_with_exclamation post_receive_url.active? - td = checked_image_with_exclamation post_receive_url.use_triggers? + td + = post_receive_url.url + + td + = post_receive_mode post_receive_url + + td.tick + = checked_image_with_exclamation post_receive_url.active? + + td.tick + = checked_image_with_exclamation post_receive_url.use_triggers? + td - post_receive_url.triggers.each do |trigger| - span.label.label-info = trigger + span.label.label-info + = trigger td.buttons - if User.current.git_allowed_to?(:edit_repository_post_receive_urls, @repository) - = link_to l(:button_edit), edit_repository_post_receive_url_path(@repository, post_receive_url), class: 'icon icon-edit modal-box' - = link_to l(:button_delete), repository_post_receive_url_path(@repository, post_receive_url), remote: true, method: :delete, data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del' + = link_to l(:button_edit), + edit_repository_post_receive_url_path(@repository, post_receive_url), + remote: true, + class: 'icon icon-edit' + = link_to l(:button_delete), + repository_post_receive_url_path(@repository, post_receive_url), + remote: true, + method: :delete, + data: { confirm: l(:text_are_you_sure) }, + class: 'icon icon-del' - else - p.nodata = l(:label_no_data) + p.nodata = l :label_no_data diff --git a/app/views/repository_post_receive_urls/new.js.erb b/app/views/repository_post_receive_urls/new.js.erb new file mode 100644 index 00000000000..ced54c6be93 --- /dev/null +++ b/app/views/repository_post_receive_urls/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_post_receive_urls/new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_post_receive_urls/update.js.erb b/app/views/repository_post_receive_urls/update.js.erb deleted file mode 100644 index 0c70e78c01c..00000000000 --- a/app/views/repository_post_receive_urls/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_post_receive_urls/edit') %> diff --git a/app/views/repository_protected_branches/edit.html.slim b/app/views/repository_protected_branches/_edit_modal.html.slim similarity index 69% rename from app/views/repository_protected_branches/edit.html.slim rename to app/views/repository_protected_branches/_edit_modal.html.slim index 52dce6fc19d..5f01cf782be 100644 --- a/app/views/repository_protected_branches/edit.html.slim +++ b/app/views/repository_protected_branches/_edit_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_protected_branch_edit + = labelled_form_for :repository_protected_branche, @protected_branch, url: repository_protected_branch_path(@repository, @protected_branch), authenticity_token: form_authenticity_token, html: { method: :put, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_save) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_protected_branches/_form.html.slim b/app/views/repository_protected_branches/_form.html.slim index 81679ced160..7bb673d3436 100644 --- a/app/views/repository_protected_branches/_form.html.slim +++ b/app/views/repository_protected_branches/_form.html.slim @@ -1,4 +1,4 @@ -.flash-messages= error_messages_for 'protected_branch' +.flash-messages = error_messages_for 'protected_branch' .box p = f.text_field :path, required: true, size: 65, label: l(:label_branch_path) diff --git a/app/views/repository_protected_branches/new.html.slim b/app/views/repository_protected_branches/_new_modal.html.slim similarity index 68% rename from app/views/repository_protected_branches/new.html.slim rename to app/views/repository_protected_branches/_new_modal.html.slim index 8424a5b4763..2ce1f957df8 100644 --- a/app/views/repository_protected_branches/new.html.slim +++ b/app/views/repository_protected_branches/_new_modal.html.slim @@ -1,6 +1,12 @@ +h3.title = l :label_protected_branch_add + = labelled_form_for :repository_protected_branche, @protected_branch, url: repository_protected_branches_path(@repository), authenticity_token: form_authenticity_token, html: { method: :post, class: 'tabular', remote: true } do |f| = render partial: 'form', locals: { f: f } + .buttons + = submit_tag l(:button_add) + ' + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/repository_protected_branches/create.js.erb b/app/views/repository_protected_branches/create.js.erb deleted file mode 100644 index 50e48e3e168..00000000000 --- a/app/views/repository_protected_branches/create.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_protected_branches/new') %> diff --git a/app/views/repository_protected_branches/edit.js.erb b/app/views/repository_protected_branches/edit.js.erb new file mode 100644 index 00000000000..c57013fbf50 --- /dev/null +++ b/app/views/repository_protected_branches/edit.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_protected_branches/edit_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_protected_branches/index.html.slim b/app/views/repository_protected_branches/index.html.slim index 77108705a4c..d5421e8a853 100644 --- a/app/views/repository_protected_branches/index.html.slim +++ b/app/views/repository_protected_branches/index.html.slim @@ -1,22 +1,24 @@ div - - if User.current.git_allowed_to?(:create_repository_protected_branches, @repository) + - if User.current.git_allowed_to? :create_repository_protected_branches, @repository .contextual = link_to l(:label_protected_branch_add), new_repository_protected_branch_path(@repository), - class: 'icon icon-add modal-box' + remote: true, class: 'icon icon-add' h3 = l(:label_protected_branches) = link_to "(#{l(:label_gitolite_documentation)})", 'https://gitolite.com/gitolite/conf.html#rules', class: 'external' - if @repository_protected_branches.any? - table#protected_branches.table.table-hover data-update-url="#{sort_repository_protected_branches_url}" style="opacity: #{@repository.protected_branches_enabled? ? '1' : '0.5'};" + table#protected_branches.list[ + data-update-url="#{sort_repository_protected_branches_url}" + style="opacity: #{@repository.protected_branches_enabled? ? '1' : '0.5'}"] thead tr th - th = l(:label_permissions) - th = l(:label_branch_path) - th = l(:label_user_list) + th = l :label_permissions + th = l :label_branch_path + th = l :label_user_list th tbody @@ -26,26 +28,43 @@ div span.handle | [drag] td - - color = protected_branch.permissions == '-' ? 'important' : 'success' + - color = protected_branch.permissions == '-' ? 'error' : 'success' span.label class="label-#{color}" = protected_branch.permissions td style='font-family: Consolas;' = protected_branch.path - td = protected_branch.users.map { |u| link_to(u) }.join(', ').html_safe + td + - cnt = 0 + - protected_branch.users.each do |user| + - if cnt.positive? + ' , + = link_to_user user + - cnt += 1 td.buttons - if User.current.git_allowed_to?(:edit_repository_protected_branches, @repository) - = link_to l(:button_edit), edit_repository_protected_branch_path(@repository, protected_branch), class: 'icon icon-edit modal-box' - = link_to l(:button_clone), clone_repository_protected_branch_path(@repository, protected_branch), class: 'icon icon-copy modal-box' - = link_to l(:button_delete), repository_protected_branch_path(@repository, protected_branch), remote: true, method: :delete, data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del' + = link_to l(:button_edit), + edit_repository_protected_branch_path(@repository, protected_branch), + remote: true, + class: 'icon icon-edit' + = link_to l(:button_clone), + clone_repository_protected_branch_path(@repository, protected_branch), + remote: true, + class: 'icon icon-copy' + = link_to l(:button_delete), + repository_protected_branch_path(@repository, protected_branch), + remote: true, + method: :delete, + data: { confirm: l(:text_are_you_sure) }, + class: 'icon icon-del' - unless @repository.protected_branches_enabled? - em = l(:protected_branches_reminder) + em = l :protected_branches_reminder - else - p.nodata = l(:label_no_data) + p.nodata = l :label_no_data javascript: $(document).ready(function() { setSortableElement('#protected_branches tbody', '#protected_branches'); }); diff --git a/app/views/repository_protected_branches/new.js.erb b/app/views/repository_protected_branches/new.js.erb new file mode 100644 index 00000000000..fc6c9841b29 --- /dev/null +++ b/app/views/repository_protected_branches/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render partial: 'repository_protected_branches/new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/app/views/repository_protected_branches/update.js.erb b/app/views/repository_protected_branches/update.js.erb deleted file mode 100644 index bd8051ecf77..00000000000 --- a/app/views/repository_protected_branches/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -<%= js_render_template('#modal-box', 'repository_protected_branches/edit') %> diff --git a/app/views/settings/_redmine_git_hosting.html.slim b/app/views/settings/_redmine_git_hosting.html.slim index 5336a81087c..dbabe2a8467 100644 --- a/app/views/settings/_redmine_git_hosting.html.slim +++ b/app/views/settings/_redmine_git_hosting.html.slim @@ -1,17 +1,17 @@ = render partial: 'common/git_hosting_js_headers' - content_for :header_tags do - = additionals_library_load(:select2) + = additionals_library_load :select2 span - = l(:label_need_help) + ':' - ' + = l :label_need_help + ' : = link_to l(:label_redmine_git_hosting_wiki), RedmineGitHosting::Config::GITHUB_WIKI, class: 'external' br span - = l(:label_open_issue) + ':' - ' + = l :label_open_issue + ' : = link_to l(:label_redmine_git_hosting_issue), RedmineGitHosting::Config::GITHUB_ISSUE, class: 'external' br @@ -20,4 +20,4 @@ br = render_tabs gitolite_plugin_settings_tabs javascript: - $(document).ready(function() { setSettingsActiveTab(); setBootstrapSwitch(); }); + $(document).ready(function() { setSettingsActiveTab(); }); diff --git a/app/views/settings/install_gitolite_hooks.js.erb b/app/views/settings/install_gitolite_hooks.js.erb index 6845af27ac5..cf4ed638eca 100644 --- a/app/views/settings/install_gitolite_hooks.js.erb +++ b/app/views/settings/install_gitolite_hooks.js.erb @@ -1 +1,2 @@ -<%= js_render_partial('#install_gitolite_hooks', 'settings/redmine_git_hosting/install_hooks_result') %> +$('#ajax-modal').html("<%= escape_javascript(render partial: 'settings/redmine_git_hosting/install_hooks_result') %>"); +showModal('ajax-modal', '600px'); diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_access.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_access.html.slim index dfb53a23b30..8a6ade7bf0b 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_access.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_access.html.slim @@ -1,49 +1,46 @@ / Gitolite Access Config -- ssh_server_domain = RedmineGitHosting::Config.get_setting(:ssh_server_domain) -- http_server_domain = RedmineGitHosting::Config.get_setting(:http_server_domain) -- https_server_domain = RedmineGitHosting::Config.get_setting(:https_server_domain) -- http_server_subdir = RedmineGitHosting::Config.get_setting(:http_server_subdir) +ruby: + ssh_server_domain = RedmineGitHosting::Config.get_setting :ssh_server_domain + http_server_domain = RedmineGitHosting::Config.get_setting :http_server_domain + https_server_domain = RedmineGitHosting::Config.get_setting :https_server_domain + http_server_subdir = RedmineGitHosting::Config.get_setting :http_server_subdir + gitolite_http_by_default = RedmineGitHosting::Config.get_setting :gitolite_http_by_default -- gitolite_http_by_default = RedmineGitHosting::Config.get_setting(:gitolite_http_by_default) - -h3 = l(:label_gitolite_access_config) +h3 = l :label_gitolite_access_config p - label = l(:label_ssh_server_domain) - = text_field_tag 'settings[ssh_server_domain]', ssh_server_domain, size: 60 + label = l :label_ssh_server_domain + = text_field_tag 'settings[ssh_server_domain]', ssh_server_domain, size: 60, required: true br em.info - = l(:label_default_domain_name) + ' :' + = l :label_default_domain_name + ' : = Setting.host_name.split('/').first p - label = l(:label_http_server_domain) - = text_field_tag 'settings[http_server_domain]', http_server_domain, size: 60 + label = l :label_http_server_domain + = text_field_tag 'settings[http_server_domain]', http_server_domain, size: 60, required: true br em.info - = l(:label_default_domain_name) + ' :' + = l :label_default_domain_name + ' : = Setting.host_name.split('/').first p - label = l(:label_https_server_domain) + label = l :label_https_server_domain = text_field_tag 'settings[https_server_domain]', https_server_domain, size: 60 br em.info - = l(:label_https_server_domain_desc) + = l :label_https_server_domain_desc p - label == l(:label_http_server_subdir) + label = l :label_http_server_subdir = text_field_tag 'settings[http_server_subdir]', http_server_subdir, size: 60 p - label = l(:label_gitolite_http_by_default) + label = l :label_gitolite_http_by_default = select_tag 'settings[gitolite_http_by_default]', options_for_select(RepositoryGitExtra::SMART_HTTP_OPTIONS, gitolite_http_by_default) -p - = additionals_settings_checkbox :show_repositories_url, - value: RedmineGitHosting::Config.get_setting(:show_repositories_url, true), - value_is_bool: true - p = additionals_settings_checkbox :gitolite_daemon_by_default, value: RedmineGitHosting::Config.get_setting(:gitolite_daemon_by_default, true), diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_cache.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_cache.html.slim index 9a42368e5a7..7c9c345abac 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_cache.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_cache.html.slim @@ -1,30 +1,37 @@ / Gitolite Cache Config -- gitolite_cache_max_time = RedmineGitHosting::Config.get_setting(:gitolite_cache_max_time) -- gitolite_cache_max_size = RedmineGitHosting::Config.get_setting(:gitolite_cache_max_size) -- gitolite_cache_max_elements = RedmineGitHosting::Config.get_setting(:gitolite_cache_max_elements) -- gitolite_cache_adapter = RedmineGitHosting::Config.get_setting(:gitolite_cache_adapter) +ruby: + gitolite_cache_max_time = RedmineGitHosting::Config.get_setting :gitolite_cache_max_time + gitolite_cache_max_size = RedmineGitHosting::Config.get_setting :gitolite_cache_max_size + gitolite_cache_max_elements = RedmineGitHosting::Config.get_setting :gitolite_cache_max_elements + gitolite_cache_adapter = RedmineGitHosting::Config.get_setting :gitolite_cache_adapter -h3 = l(:label_gitolite_cache_config) +h3 = l :label_gitolite_cache_config p - label = l(:label_gitolite_cache_max_time) + label = l :label_gitolite_cache_max_time = select_tag 'settings[gitolite_cache_max_time]', options_for_select(git_cache_options, gitolite_cache_max_time) br p - label = l(:label_gitolite_cache_max_size) - = text_field_tag 'settings[gitolite_cache_max_size]', gitolite_cache_max_size, size: 20 + label = l :label_gitolite_cache_max_size + = number_field_tag 'settings[gitolite_cache_max_size]', + gitolite_cache_max_size, + size: 20, + min: -1 em< ' MB br p - label = l(:label_gitolite_cache_max_elements) - = text_field_tag 'settings[gitolite_cache_max_elements]', gitolite_cache_max_elements, size: 20 + label = l :label_gitolite_cache_max_elements + = number_field_tag 'settings[gitolite_cache_max_elements]', + gitolite_cache_max_elements, + size: 20, + min: 1 br p - label = l(:label_gitolite_cache_adapter) + label = l :label_gitolite_cache_adapter = select_tag 'settings[gitolite_cache_adapter]', options_for_select(GitCache::CACHE_ADAPTERS, gitolite_cache_adapter) br - em = l(:label_gitolite_cache_adapter_desc) + em = l :label_gitolite_cache_adapter_desc diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_file.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_file.html.slim index a849bb01429..ca4c21c631a 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_file.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_file.html.slim @@ -1,23 +1,24 @@ / Gitolite Config File -- gitolite_config_file = RedmineGitHosting::Config.get_setting(:gitolite_config_file) -- gitolite_identifier_prefix = RedmineGitHosting::Config.get_setting(:gitolite_identifier_prefix) -- gitolite_identifier_strip_user_id = RedmineGitHosting::Config.get_setting(:gitolite_identifier_strip_user_id, true) +ruby: + gitolite_config_file = RedmineGitHosting::Config.get_setting(:gitolite_config_file) + gitolite_identifier_prefix = RedmineGitHosting::Config.get_setting(:gitolite_identifier_prefix) + gitolite_identifier_strip_user_id = RedmineGitHosting::Config.get_setting(:gitolite_identifier_strip_user_id, true) + disable_button = gitolite_config_file == RedmineGitHosting::Config::GITOLITE_DEFAULT_CONFIG_FILE -- disable_button = (gitolite_config_file == RedmineGitHosting::Config::GITOLITE_DEFAULT_CONFIG_FILE ? true : false) - -h3 = l(:label_gitolite_config_file) +h3 = l :label_gitolite_config_file p - label = l(:label_gitolite_config_file) - = text_field_tag 'settings[gitolite_config_file]', gitolite_config_file, size: 60 + label = l :label_gitolite_config_file + = text_field_tag 'settings[gitolite_config_file]', gitolite_config_file, size: 60, required: true p - label = l(:label_gitolite_identifier_prefix) - = hidden_field_tag "settings[gitolite_identifier_prefix]", gitolite_identifier_prefix if disable_button - = text_field_tag "settings[gitolite_identifier_prefix]", gitolite_identifier_prefix, size: 60, disabled: disable_button + label = l :label_gitolite_identifier_prefix + - if disable_button + = hidden_field_tag 'settings[gitolite_identifier_prefix]', gitolite_identifier_prefix + = text_field_tag 'settings[gitolite_identifier_prefix]', gitolite_identifier_prefix, size: 60, disabled: disable_button br em.info - = l(:label_gitolite_identifier_prefix_desc) + = l :label_gitolite_identifier_prefix_desc p = additionals_settings_checkbox :gitolite_identifier_strip_user_id, @@ -26,20 +27,29 @@ p disabled: disable_button br em.info - = l(:label_gitolite_identifier_strip_user_id_desc) + = l :label_gitolite_identifier_strip_user_id_desc br .git_hosting_access_box - h3 = l(:label_ssh_keys_current_access_patterns) + h3 = l :label_ssh_keys_current_access_patterns - - gitolite_identifier_suffix = !gitolite_identifier_strip_user_id ? '_user_id' : '' + - gitolite_identifier_suffix = gitolite_identifier_strip_user_id ? '' : '_user_id' pre - markdown: - SSH Key : #{gitolite_identifier_prefix}admin#{gitolite_identifier_suffix}@redmine_1394507971_600081.pub - SSH Key : #{gitolite_identifier_prefix}bob#{gitolite_identifier_suffix}@redmine_1394507971_600081.pub - - repo repositories/test - RW+ = #{gitolite_identifier_prefix}admin#{gitolite_identifier_suffix} #{gitolite_identifier_prefix}john#{gitolite_identifier_suffix} - RW = #{gitolite_identifier_prefix}bob#{gitolite_identifier_suffix} alice - R = #{gitolite_identifier_prefix}reporter#{gitolite_identifier_suffix} mike gitweb + div + | SSH Key: #{gitolite_identifier_prefix}admin#{gitolite_identifier_suffix}@redmine_1394507971_600081.pub + div + | SSH Key: #{gitolite_identifier_prefix}bob#{gitolite_identifier_suffix}@redmine_1394507971_600081.pub + + br + + div + | repo repositories/test + + div + | RW+ = #{gitolite_identifier_prefix}admin#{gitolite_identifier_suffix} + | #{gitolite_identifier_prefix}john#{gitolite_identifier_suffix} + div + | RW = #{gitolite_identifier_prefix}bob#{gitolite_identifier_suffix} alice + div + | R = #{gitolite_identifier_prefix}reporter#{gitolite_identifier_suffix} mike gitweb diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_global.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_global.html.slim index e2c4857f8a0..c099e022899 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_global.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_global.html.slim @@ -1,43 +1,55 @@ / Gitolite Global Config -- gitolite_recycle_bin_expiration_time = RedmineGitHosting::Config.get_setting(:gitolite_recycle_bin_expiration_time) -- gitolite_temp_dir = RedmineGitHosting::Config.get_setting(:gitolite_temp_dir) -- gitolite_log_level = RedmineGitHosting::Config.get_setting(:gitolite_log_level) -- git_config_username = RedmineGitHosting::Config.get_setting(:git_config_username) -- git_config_email = RedmineGitHosting::Config.get_setting(:git_config_email) +ruby: + gitolite_recycle_bin_expiration_time = RedmineGitHosting::Config.get_setting :gitolite_recycle_bin_expiration_time + gitolite_temp_dir = RedmineGitHosting::Config.get_setting :gitolite_temp_dir + gitolite_log_level = RedmineGitHosting::Config.get_setting :gitolite_log_level + git_config_username = RedmineGitHosting::Config.get_setting :git_config_username + git_config_email = RedmineGitHosting::Config.get_setting :git_config_email -h3 = l(:label_gitolite_global_config) +h3 = l :label_gitolite_global_config p - label = l(:label_gitolite_temp_dir) - = text_field_tag 'settings[gitolite_temp_dir]', gitolite_temp_dir, size: 60 + label = l :label_gitolite_temp_dir + = text_field_tag 'settings[gitolite_temp_dir]', gitolite_temp_dir, size: 60, required: true br em.info - = l(:label_gitolite_temp_dir_desc) + = l :label_gitolite_temp_dir_desc p - label = l(:label_gitolite_recycle_bin_expiration_time) - = text_field_tag 'settings[gitolite_recycle_bin_expiration_time]', gitolite_recycle_bin_expiration_time, size: 10 + label = l :label_gitolite_recycle_bin_expiration_time + = number_field_tag 'settings[gitolite_recycle_bin_expiration_time]', + gitolite_recycle_bin_expiration_time, + size: 10, + required: true, + min: -1 + br em.info - = l(:label_gitolite_recycle_bin_expiration_time_desc) + = l :label_gitolite_recycle_bin_expiration_time_desc p - label = l(:label_gitolite_log_level) + label = l :label_gitolite_log_level = select_tag 'settings[gitolite_log_level]', options_for_select(log_level_options, gitolite_log_level) br em.info - = l(:label_gitolite_log_level_desc) + = l :label_gitolite_log_level_desc p - label = l(:label_git_config_username) - = text_field_tag 'settings[git_config_username]', "#{git_config_username}", size: 60 + label = l :label_git_config_username + = text_field_tag 'settings[git_config_username]', + git_config_username.to_s, + size: 60, + required: true br em.info - = l(:label_git_config_username_desc) + = l :label_git_config_username_desc p - label = l(:label_git_config_email) - = text_field_tag 'settings[git_config_email]', "#{git_config_email}", size: 60 + label = l :label_git_config_email + = text_field_tag 'settings[git_config_email]', + git_config_email.to_s, + size: 60, + required: true br em.info - = l(:label_git_config_email_desc) + = l :label_git_config_email_desc diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_hooks.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_hooks.html.slim index 796f659b66f..c5a8d1bab98 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_hooks.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_hooks.html.slim @@ -1,46 +1,45 @@ / Gitolite Hooks Config -- gitolite_hooks_url = RedmineGitHosting::Config.get_setting(:gitolite_hooks_url) +- gitolite_hooks_url = RedmineGitHosting::Config.get_setting :gitolite_hooks_url .contextual = link_to font_awesome_icon('fas_rocket', post_text: l(:label_install_gitolite_hooks), class: 'fa-lg'), install_gitolite_hooks_path('redmine_git_hosting'), remote: true -h3 = l(:label_gitolite_hooks_config) +h3 = l :label_gitolite_hooks_config .container - .row - .col-md-6 style='vertical-align: top;' - p - = additionals_settings_checkbox :gitolite_overwrite_existing_hooks, - value: RedmineGitHosting::Config.get_setting(:gitolite_overwrite_existing_hooks, true), - value_is_bool: true - - p - = additionals_settings_checkbox :gitolite_hooks_are_asynchronous, - value: RedmineGitHosting::Config.get_setting(:gitolite_hooks_are_asynchronous, true), - value_is_bool: true - - p - = additionals_settings_checkbox :gitolite_hooks_debug, - value: RedmineGitHosting::Config.get_setting(:gitolite_hooks_debug, true), - value_is_bool: true - - p - label = l(:label_gitolite_hooks_url) - = text_field_tag 'settings[gitolite_hooks_url]', gitolite_hooks_url, size: 60 - br - em.info - = l(:label_default_gitolite_hooks_url) + ' :' - = "#{Setting.protocol}://#{Setting.host_name.split('/').first}" - - p - label = l(:label_gitolite_hooks_url) - span.label.label-info = RedmineGitHosting::Config.gitolite_hooks_url - - p - label= l(:label_gitolite_hooks_namespace) - span.label.label-info = RedmineGitHosting::Config.gitolite_hooks_namespace - - .col-md-6 - #install_gitolite_hooks + .col-md-6 style='vertical-align: top;' + p + = additionals_settings_checkbox :gitolite_overwrite_existing_hooks, + value: RedmineGitHosting::Config.get_setting(:gitolite_overwrite_existing_hooks, true), + value_is_bool: true + + p + = additionals_settings_checkbox :gitolite_hooks_are_asynchronous, + value: RedmineGitHosting::Config.get_setting(:gitolite_hooks_are_asynchronous, true), + value_is_bool: true + + p + = additionals_settings_checkbox :gitolite_hooks_debug, + value: RedmineGitHosting::Config.get_setting(:gitolite_hooks_debug, true), + value_is_bool: true + + p + label = l :label_gitolite_hooks_url + = url_field_tag 'settings[gitolite_hooks_url]', gitolite_hooks_url, size: 60, required: true + br + em.info + = l :label_default_gitolite_hooks_url + ' : + = "#{Setting.protocol}://#{Setting.host_name.split('/').first}" + + p + label = l :label_gitolite_hooks_url + span.label.label-info = RedmineGitHosting::Config.gitolite_hooks_url + + p + label = l :label_gitolite_hooks_namespace + span.label.label-info = RedmineGitHosting::Config.gitolite_hooks_namespace + +#install_gitolite_hooks diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_notify.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_notify.html.slim index 39081418776..6552fb8e0fe 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_notify.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_notify.html.slim @@ -1,10 +1,11 @@ / Gitolite Notifications Config -- gitolite_notify_global_prefix = RedmineGitHosting::Config.get_setting(:gitolite_notify_global_prefix) -- gitolite_notify_global_sender_address = RedmineGitHosting::Config.get_setting(:gitolite_notify_global_sender_address) -- gitolite_notify_global_include = RedmineGitHosting::Config.get_setting(:gitolite_notify_global_include) -- gitolite_notify_global_exclude = RedmineGitHosting::Config.get_setting(:gitolite_notify_global_exclude) +ruby: + gitolite_notify_global_prefix = RedmineGitHosting::Config.get_setting :gitolite_notify_global_prefix + gitolite_notify_global_sender_address = RedmineGitHosting::Config.get_setting :gitolite_notify_global_sender_address + gitolite_notify_global_include = RedmineGitHosting::Config.get_setting :gitolite_notify_global_include + gitolite_notify_global_exclude = RedmineGitHosting::Config.get_setting :gitolite_notify_global_exclude -h3 = l(:label_gitolite_notify_config) +h3 = l :label_gitolite_notify_config p = additionals_settings_checkbox :gitolite_notify_by_default, @@ -12,15 +13,15 @@ p value_is_bool: true p - label = l(:label_gitolite_notify_global_prefix) + label = l :label_gitolite_notify_global_prefix = text_field_tag 'settings[gitolite_notify_global_prefix]', gitolite_notify_global_prefix, size: 60 p - label = l(:label_gitolite_notify_global_sender_address) + label = l :label_gitolite_notify_global_sender_address = text_field_tag 'settings[gitolite_notify_global_sender_address]', gitolite_notify_global_sender_address, size: 60 p - label = l(:label_gitolite_notify_global_include) + label = l :label_gitolite_notify_global_include = additionals_select2_tag 'settings[gitolite_notify_global_include]', options_for_select(gitolite_notify_global_include.map { |mail| [mail, mail] }, gitolite_notify_global_include), data: gitolite_notify_global_include, @@ -29,7 +30,7 @@ p tags: true p - label = l(:label_gitolite_notify_global_exclude) + label = l :label_gitolite_notify_global_exclude = additionals_select2_tag 'settings[gitolite_notify_global_exclude]', options_for_select(gitolite_notify_global_exclude.map { |mail| [mail, mail] }, gitolite_notify_global_exclude), data: gitolite_notify_global_exclude, diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_ssh.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_ssh.html.slim index c1d5b8d6a36..d8d6f10cfd2 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_ssh.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_ssh.html.slim @@ -1,28 +1,46 @@ / Gitolite SSH Config -- gitolite_user = RedmineGitHosting::Config.get_setting(:gitolite_user) -- gitolite_server_host = RedmineGitHosting::Config.get_setting(:gitolite_server_host) -- gitolite_server_port = RedmineGitHosting::Config.get_setting(:gitolite_server_port) -- gitolite_ssh_private_key = RedmineGitHosting::Config.get_setting(:gitolite_ssh_private_key) -- gitolite_ssh_public_key = RedmineGitHosting::Config.get_setting(:gitolite_ssh_public_key) +ruby: + gitolite_user = RedmineGitHosting::Config.get_setting :gitolite_user + gitolite_server_host = RedmineGitHosting::Config.get_setting :gitolite_server_host + gitolite_server_port = RedmineGitHosting::Config.get_setting :gitolite_server_port + gitolite_ssh_private_key = RedmineGitHosting::Config.get_setting :gitolite_ssh_private_key + gitolite_ssh_public_key = RedmineGitHosting::Config.get_setting :gitolite_ssh_public_key -h3 = l(:label_gitolite_ssh_config) +h3 = l :label_gitolite_ssh_config p label = l(:label_gitolite_user) - = text_field_tag 'settings[gitolite_user]', gitolite_user, size: 20 + = text_field_tag 'settings[gitolite_user]', + gitolite_user, + size: 20, + required: true p label = l(:label_gitolite_ssh_private_key) - = text_field_tag 'settings[gitolite_ssh_private_key]', gitolite_ssh_private_key, size: 110 + = text_field_tag 'settings[gitolite_ssh_private_key]', + gitolite_ssh_private_key, + size: 110, + required: true p label = l(:label_gitolite_ssh_public_key) - = text_field_tag 'settings[gitolite_ssh_public_key]', gitolite_ssh_public_key, size: 110 + = text_field_tag 'settings[gitolite_ssh_public_key]', + gitolite_ssh_public_key, + size: 110, + required: true p label = l(:label_gitolite_server_host) - = text_field_tag 'settings[gitolite_server_host]', gitolite_server_host, size: 20 + = text_field_tag 'settings[gitolite_server_host]', + gitolite_server_host, + size: 20, + required: true p label = l(:label_gitolite_server_port) - = text_field_tag 'settings[gitolite_server_port]', gitolite_server_port, size: 5 + = number_field_tag 'settings[gitolite_server_port]', + gitolite_server_port, + size: 5, + min: 1, + max: 65_535, + required: true diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_storage.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_storage.html.slim index 6a9803af379..dcdcc6d35ee 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_storage.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_storage.html.slim @@ -7,14 +7,20 @@ h3 = l(:label_gitolite_storage_config) p label = l(:label_gitolite_global_storage_dir) - = text_field_tag 'settings[gitolite_global_storage_dir]', gitolite_global_storage_dir, size: 60 + = text_field_tag 'settings[gitolite_global_storage_dir]', + gitolite_global_storage_dir, + size: 60, + required: true br em.info = l(:label_gitolite_global_storage_dir_desc) p label = l(:label_gitolite_recycle_bin_dir) - = text_field_tag 'settings[gitolite_recycle_bin_dir]', gitolite_recycle_bin_dir, size: 60 + = text_field_tag 'settings[gitolite_recycle_bin_dir]', + gitolite_recycle_bin_dir, + size: 60, + required: true br em.info = l(:label_gitolite_recycle_bin_dir_desc) diff --git a/app/views/settings/redmine_git_hosting/_gitolite_config_test.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_config_test.html.slim index 996d04b41af..ba6bed3ac11 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_config_test.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_config_test.html.slim @@ -1,6 +1,6 @@ -h3 = l(:label_permissions_header) +h3 = l :label_permissions_header -table.table.table-hover +table.list.git-results tr td = l(:label_temp_dir_writeable) td = render_temp_dir_writeable(RedmineGitHosting::Config.temp_dir_writeable?(reset: true), RedmineGitHosting::Config.gitolite_admin_dir) @@ -17,26 +17,27 @@ table.table.table-hover tr td = l(:label_sudo_redmine_to_gitolite_user) - td = image_tag (RedmineGitHosting::Config.can_redmine_sudo_to_gitolite_user? ? 'true.png' : 'exclamation.png') + td + = image_tag(RedmineGitHosting::Config.can_redmine_sudo_to_gitolite_user? ? 'true.png' : 'exclamation.png') tr - td = l(:label_gitolite_bin_dir) + td = l :label_gitolite_bin_dir td - if RedmineGitHosting::Config.gitolite_bin_dir span.label.label-success RedmineGitHosting::Config.gitolite_bin_dir - else - = image_tag('exclamation.png') + = image_tag 'exclamation.png' tr - td= l(:label_gitolite_lib_dir) + td = l :label_gitolite_lib_dir td - if RedmineGitHosting::Config.gitolite_lib_dir span.label.label-success RedmineGitHosting::Config.gitolite_lib_dir - else - = image_tag('exclamation.png') + = image_tag 'exclamation.png' tr - td= l(:label_gitolite_local_code_dir) + td = l :label_gitolite_local_code_dir td - if RedmineGitHosting::Config.gitolite_local_code_dir span.label.label-success = RedmineGitHosting::Config.gitolite_local_code_dir @@ -46,28 +47,29 @@ table.table.table-hover - gitolite_checks = RedmineGitHosting::Config.check_hooks_install! tr - td = l(:label_gitolite_hooks_installed) + td = l :label_gitolite_hooks_installed td = render_gitolite_params_status(gitolite_checks[:hook_files]) tr - td = l(:label_gitolite_hooks_params_installed) + td = l :label_gitolite_hooks_params_installed td = render_gitolite_params_status(gitolite_checks[:global_params]) tr - td = l(:label_gitolite_mailer_params_installed) + td = l :label_gitolite_mailer_params_installed td = render_gitolite_params_status(gitolite_checks[:mailer_params]) tr - td = l(:label_mirroring_keys_installed) - td = image_tag (RedmineGitHosting::Config.mirroring_keys_installed? ? 'true.png' : 'exclamation.png') + td = l :label_mirroring_keys_installed + td + = image_tag(RedmineGitHosting::Config.mirroring_keys_installed? ? 'true.png' : 'exclamation.png') tr - td= l(:label_git_version) + td = l :label_git_version td span.label.label-success = Repository::Xitolite.scm_version_string tr - td = l(:label_gitolite_version) + td = l :label_gitolite_version td = render_gitolite_version(RedmineGitHosting::Config.gitolite_version) tr @@ -76,24 +78,17 @@ table.table.table-hover span.label.label-success = RedmineGitHosting::Config.gitolite_repository_count tr - td= l(:label_gitolite_rugged_features) + td = l :label_gitolite_rugged_features td = render_rugged_mandatory_features = render_rugged_optional_features - tr - td = l(:label_gitolite_libgit2_version) - td - span.label.label-success = RedmineGitHosting::Config.libgit2_version - -p - label = l(:label_gitolite_banner) - -.box +br +fieldset.box.tabular + legend = l :label_gitolite_banner pre == RedmineGitHosting::Config.gitolite_banner -p - label = l(:label_path_directories) - -.box - pre == (ENV['PATH']).gsub(/:/, "
") +br +fieldset.box.tabular + legend = l(:label_path_directories) + pre == (ENV['PATH']).gsub(/:/, '
') diff --git a/app/views/settings/redmine_git_hosting/_gitolite_display_access.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_display_access.html.slim index e1a26bd6e64..a7b17682be5 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_display_access.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_display_access.html.slim @@ -1,75 +1,130 @@ / Gitolite Display Access -- gitolite_user = RedmineGitHosting::Config.get_setting(:gitolite_user) -- ssh_server_domain = RedmineGitHosting::Config.get_setting(:ssh_server_domain) -- gitolite_global_storage_dir = RedmineGitHosting::Config.get_setting(:gitolite_global_storage_dir) -- gitolite_redmine_storage_dir = RedmineGitHosting::Config.get_setting(:gitolite_redmine_storage_dir) -- http_server_subdir = RedmineGitHosting::Config.get_setting(:http_server_subdir) -- http_server_domain = RedmineGitHosting::Config.http_root_url -- https_server_domain = RedmineGitHosting::Config.https_root_url -- hierarchical_organisation = RedmineGitHosting::Config.get_setting(:hierarchical_organisation, true) +ruby: + gitolite_user = RedmineGitHosting::Config.get_setting :gitolite_user + ssh_server_domain = RedmineGitHosting::Config.get_setting :ssh_server_domain + git_shp = ssh_server_domain.match(/:\d+$/) + gitolite_global_storage_dir = RedmineGitHosting::Config.get_setting :gitolite_global_storage_dir + gitolite_redmine_storage_dir = RedmineGitHosting::Config.get_setting :gitolite_redmine_storage_dir + http_server_subdir = RedmineGitHosting::Config.get_setting :http_server_subdir + http_server_domain = RedmineGitHosting::Config.http_root_url + https_server_domain = RedmineGitHosting::Config.https_root_url + hierarchical_organisation = RedmineGitHosting::Config.get_setting :hierarchical_organisation, true .git_hosting_access_box - h3 = l(:label_repos_current_access_patterns) + h3 = l :label_repos_current_access_patterns - span == l(:display_access_setup1) + span = t :display_access_setup1_html br br - span == l(:display_access_setup2) + span = t :display_access_setup2_html br br - span == l(:display_access_setup3) + span = t :display_access_setup3_html p label = l(:label_default_repository) br - label = l(:label_storage_directory) + ' :' - == "~#{gitolite_user}/#{gitolite_global_storage_dir}#{gitolite_redmine_storage_dir}#{hierarchical_organisation ? 'project1/project2/' : ''}project3.git" + label + = l :label_storage_directory + ' : + + = "~#{gitolite_user}/#{gitolite_global_storage_dir}#{gitolite_redmine_storage_dir}" + em + = "#{'project1/project2/' if hierarchical_organisation}project3.git" br - label = l(:label_ssh_access) + ' :' - - gitSHP = ssh_server_domain.match(/:\d+$/) - == "#{gitSHP ? 'ssh://' : ''}#{gitolite_user}@#{ssh_server_domain}#{gitSHP ? '/' : ':'}#{gitolite_redmine_storage_dir}#{hierarchical_organisation ? 'project1/project2/' : ''}project3.git" + label + = l :label_ssh_access + ' : + + = "#{'ssh://' if git_shp}#{gitolite_user}@#{ssh_server_domain}#{git_shp ? '/' : ':'}#{gitolite_redmine_storage_dir}" + em + = "#{'project1/project2/' if hierarchical_organisation}project3.git" br - label = l(:label_http_access) + ' :' - == "http://redmine-user@#{http_server_domain}/#{http_server_subdir}#{hierarchical_organisation ? 'project1/project2/' : ''}project3.git" + label + = l :label_http_access + ' : + + | http:// + em + | redmine-user + = "@#{https_server_domain}/#{http_server_subdir}" + em + = "#{'project1/project2/' if hierarchical_organisation}project3.git" br - label = l(:label_https_access) + ' :' - == "https://redmine-user@#{https_server_domain}/#{http_server_subdir}#{hierarchical_organisation ? 'project1/project2/' : ''}project3.git" + label + = l :label_https_access + ' : + + | https:// + em + | redmine-user + = "@#{https_server_domain}/#{http_server_subdir}" + em + = "#{'project1/project2/' if hierarchical_organisation}project3.git" p - label = l(:label_example_repository) + label = l :label_example_repository br - label = l(:label_storage_directory) + ' :' - == "~#{gitolite_user}/#{gitolite_global_storage_dir}#{gitolite_redmine_storage_dir}#{hierarchical_organisation ? 'project1/project2/project3/' : ''}example.git" + label + = l :label_storage_directory + ' : + + = "~#{gitolite_user}/#{gitolite_global_storage_dir}#{gitolite_redmine_storage_dir}" + em + = "#{'project1/project2/project3/' if hierarchical_organisation}example.git" br - label = l(:label_ssh_access) + ' :' - - gitSHP = ssh_server_domain.match(/:\d+$/) - == "#{gitSHP ? 'ssh://' : ''}#{gitolite_user}@#{ssh_server_domain}#{gitSHP ? '/' : ':'}#{gitolite_redmine_storage_dir}#{hierarchical_organisation ? 'project1/project2/project3/' : ''}example.git" + label + = l :label_ssh_access + ' : + + = "#{'ssh://' if git_shp}#{gitolite_user}@#{ssh_server_domain}#{git_shp ? '/' : ':'}#{gitolite_redmine_storage_dir}" + em + = "#{'project1/project2/project3/' if hierarchical_organisation}example.git" br - label = l(:label_http_access) + ' :' - == "http://redmine-user@#{http_server_domain}/#{http_server_subdir}#{hierarchical_organisation ? 'project1/project2/project3/' : ''}example.git" + label + = l :label_http_access + ' : + + | http:// + em + | redmine-user + = "@#{https_server_domain}/#{http_server_subdir}" + em + = "#{'project1/project2/project3/' if hierarchical_organisation}example.git" br - label = l(:label_https_access) + ' :' - == "https://redmine-user@#{https_server_domain}/#{http_server_subdir}#{hierarchical_organisation ? 'project1/project2/project3/' : ''}example.git" + label + = l :label_https_access + ' : + + | https:// + em + | redmine-user + = "@#{https_server_domain}/#{http_server_subdir}" + em + = "#{'project1/project2/project3/' if hierarchical_organisation}example.git" br br - label = l(:label_etcetera) + '...' + label + = l :label_etcetera + | ... - == l(:display_access_emphasis) + = t :display_access_emphasis_html + ' == hierarchical_organisation ? l(:display_access_hierarchical) : l(:display_access_flat) diff --git a/app/views/settings/redmine_git_hosting/_gitolite_recycle_bin.html.slim b/app/views/settings/redmine_git_hosting/_gitolite_recycle_bin.html.slim index 74d18566916..effd9f1724d 100644 --- a/app/views/settings/redmine_git_hosting/_gitolite_recycle_bin.html.slim +++ b/app/views/settings/redmine_git_hosting/_gitolite_recycle_bin.html.slim @@ -1,7 +1,7 @@ h3 = l(:label_empty_recycle_bin) - if !RedmineGitHosting::RecycleBin || !RedmineGitHosting::RecycleBin.content.empty? - table.table.table-hover + table.list tr th = l(:label_repository) th = l(:label_recycle_bin_content_size) diff --git a/app/views/settings/redmine_git_hosting/_install_hooks_result.html.slim b/app/views/settings/redmine_git_hosting/_install_hooks_result.html.slim index 4ec4c84bb9c..5ce8a1b032b 100644 --- a/app/views/settings/redmine_git_hosting/_install_hooks_result.html.slim +++ b/app/views/settings/redmine_git_hosting/_install_hooks_result.html.slim @@ -1,10 +1,15 @@ -table.table.table-hover +h3.title = l :label_install_hook_results + +table.list.git-results tr - td = l(:label_gitolite_hooks_installed) - td = render_gitolite_params_status(@gitolite_checks[:hook_files]) + td = l :label_gitolite_hooks_installed + td = render_gitolite_params_status @gitolite_checks[:hook_files] tr - td = l(:label_gitolite_hooks_params_installed) - td = render_gitolite_params_status(@gitolite_checks[:global_params]) + td = l :label_gitolite_hooks_params_installed + td = render_gitolite_params_status @gitolite_checks[:global_params] tr - td = l(:label_gitolite_mailer_params_installed) - td = render_gitolite_params_status(@gitolite_checks[:mailer_params]) + td = l :label_gitolite_mailer_params_installed + td = render_gitolite_params_status @gitolite_checks[:mailer_params] + +.buttons + = link_to_function l(:button_cancel), 'hideModal(this);' diff --git a/app/views/settings/redmine_git_hosting/_redmine_config.html.slim b/app/views/settings/redmine_git_hosting/_redmine_config.html.slim index 7ca992e1685..3f976317d5c 100644 --- a/app/views/settings/redmine_git_hosting/_redmine_config.html.slim +++ b/app/views/settings/redmine_git_hosting/_redmine_config.html.slim @@ -1,7 +1,7 @@ / Redmine Config - all_projects_use_git = RedmineGitHosting::Config.get_setting(:all_projects_use_git, true) -h3= l(:label_redmine_config) +h3 = l :label_redmine_config p = additionals_settings_checkbox :redmine_has_rw_access_on_all_repos, @@ -21,6 +21,8 @@ p = additionals_settings_checkbox :delete_git_repositories, value: RedmineGitHosting::Config.get_setting(:delete_git_repositories, true), value_is_bool: true + em.info + = l(:info_delete_git_repositories) p = additionals_settings_checkbox :hierarchical_organisation, diff --git a/app/views/users/index.api.rsb b/app/views/users/index.api.rsb index 5a5ba267886..14f583f41dc 100644 --- a/app/views/users/index.api.rsb +++ b/app/views/users/index.api.rsb @@ -8,7 +8,9 @@ api.array :users, api_meta(total_count: @user_count, offset: @offset, limit: @li api.lastname user.lastname api.mail user.mail api.created_on user.created_on + api.updated_on user.updated_on api.last_login_on user.last_login_on + api.passwd_changed_on user.passwd_changed_on api.array :ssh_keys do user.gitolite_public_keys.each do |key| diff --git a/app/views/users/show.api.rsb b/app/views/users/show.api.rsb deleted file mode 100644 index fa4420fdff7..00000000000 --- a/app/views/users/show.api.rsb +++ /dev/null @@ -1,51 +0,0 @@ -api.user do - api.id @user.id - api.login @user.login if User.current.admin? || (User.current == @user) - api.admin @user.admin? if User.current.admin? || (User.current == @user) - api.firstname @user.firstname - api.lastname @user.lastname - api.mail @user.mail if User.current.admin? || !@user.pref.hide_mail - api.created_on @user.created_on - api.last_login_on @user.last_login_on - api.api_key @user.api_key if User.current.admin? || (User.current == @user) - api.status @user.status if User.current.admin? - - render_api_custom_values @user.visible_custom_field_values, api - - if User.current.admin? && include_in_api_response?('groups') - api.array :groups do |groups| - @user.groups.each do |group| - api.group id: group.id, name: group.name - end - end - end - - api.array :memberships do - @memberships.each do |membership| - api.membership do - api.id membership.id - api.project :id => membership.project.id, :name => membership.project.name - api.array :roles do - membership.member_roles.each do |member_role| - if member_role.role - attrs = {:id => member_role.role.id, :name => member_role.role.name} - attrs.merge!(:inherited => true) if member_role.inherited_from.present? - api.role attrs - end - end - end - end if membership.project - end - end if include_in_api_response?('memberships') && @memberships - - api.array :ssh_keys do - @user.gitolite_public_keys.each do |key| - api.ssh_key do - api.id key.id - api.key_type key.key_type_as_string - api.title key.title - api.key key.key - end - end - end -end diff --git a/assets/javascripts/application.js b/assets/javascripts/application.js index dd9db71eb3c..d1c8d9ebd57 100644 --- a/assets/javascripts/application.js +++ b/assets/javascripts/application.js @@ -93,3 +93,23 @@ function setRecycleBinWarnings() { displayWarning(); }); } + + +// table sort +// Return a helper with preserved width of cells +var fixHelper = function(e, ui) { + ui.children().each(function() { + $(this).width($(this).width()); + }); + return ui; +}; + +function setSortableElement(element, form) { + $(element).sortable({ + helper: fixHelper, + axis: 'y', + update: function(event, ui) { + $.post($(form).data('update-url'), $(this).sortable('serialize'), null, 'script'); + } + }); +} diff --git a/assets/javascripts/bootstrap/bootstrap_alert.js b/assets/javascripts/bootstrap/bootstrap_alert.js deleted file mode 100644 index 66fb0be32c1..00000000000 --- a/assets/javascripts/bootstrap/bootstrap_alert.js +++ /dev/null @@ -1,99 +0,0 @@ -/* ========================================================== - * bootstrap-alert.js v2.3.2 - * http://getbootstrap.com/2.3.2/javascript.html#alerts - * ========================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================================================== */ - - -!function ($) { - - "use strict"; // jshint ;_; - - - /* ALERT CLASS DEFINITION - * ====================== */ - - var dismiss = '[data-dismiss="alert"]' - , Alert = function (el) { - $(el).on('click', dismiss, this.close) - } - - Alert.prototype.close = function (e) { - var $this = $(this) - , selector = $this.attr('data-target') - , $parent - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 - } - - $parent = $(selector) - - e && e.preventDefault() - - $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) - - $parent.trigger(e = $.Event('close')) - - if (e.isDefaultPrevented()) return - - $parent.removeClass('in') - - function removeElement() { - $parent - .trigger('closed') - .remove() - } - - $.support.transition && $parent.hasClass('fade') ? - $parent.on($.support.transition.end, removeElement) : - removeElement() - } - - - /* ALERT PLUGIN DEFINITION - * ======================= */ - - var old = $.fn.alert - - $.fn.alert = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('alert') - if (!data) $this.data('alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) - }) - } - - $.fn.alert.Constructor = Alert - - - /* ALERT NO CONFLICT - * ================= */ - - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this - } - - - /* ALERT DATA-API - * ============== */ - - $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) - -}(window.jQuery); diff --git a/assets/javascripts/bootstrap/bootstrap_alert_helper.js b/assets/javascripts/bootstrap/bootstrap_alert_helper.js deleted file mode 100644 index 01105d5d54f..00000000000 --- a/assets/javascripts/bootstrap/bootstrap_alert_helper.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -BootstrapAlert -*/ -function setBootstrapAlert(){ - $('.alert').each(function(index, element){ - $(element).alert(); - }); -} - -function addAlertMessage(object){ - $(object.target) - .append( - $('
') - .attr('class', 'alert fade in ' + object.type) - .html(object.message) - .prepend( - $('