I’m trying to convert a hashed path back to the project name, I’ve tried the three methods below, but I’m encountering errors, any help is appreciated.
[root@gitlab ~]# gitlab-rails console
--------------------------------------------------------------------------------
GitLab: 13.2.3 (0f9c583610f) FOSS
GitLab Shell: 13.3.0
PostgreSQL: 11.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.1)
irb(main):001:0> ProjectRepository.find_by(disk_path: '@hashed/d8/0e/d8[redacted]9a').project
Traceback (most recent call last):
1: from (irb):1
NoMethodError (undefined method `project' for nil:NilClass)
Also tried running it directly:
[~] $ sudo gitlab-rails runner "ProjectRepository.find_by(disk_path:'@hashed/d8/0e/d8[redacted]9a').project"
Please specify a valid ruby command or the path of a script to run
And finally in a script:
[~] $ ls -l
-rwxrwxr-x 1 user git 126 Aug 24 09:08 test.rb
[~] $ sudo gitlab-rails runner /home/user/script.rb
Please specify a valid ruby command or the path of a script to run.
Run 'rails runner -h' for help.
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/runner/runner_command.rb:45: unknown regexp options - bfrak
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/runner/runner_command.rb:45: syntax error, unexpected tINTEGER, expecting end-of-input
/home/user/test.rb
^~