Content
Updated by mab internet almost 7 years ago
An error occurs while browsing a Git repository using the web interface of OpenProject if a Tag (annotated or lightweight) is selected; all links to files or folders will produce an error when clicking on them.
The error has been first found in OpenProject 6.1.5 with a Git repository managed by Gitolite (Git version 2.7.4). It is confirmed in OpenProject 7.3.0 (Git version 2.16.1) and OpenProject 7.4.1 (Git version 2.7.4) with repositories managed by OpenProject.
How to replicate the error:
1\. Install OpenProject (packed installation or manual) with managed Git repositories.
2\. Create a new project and enable the module Repository in the project settings.
3\. Create a new (empty) Git repository for the project in the project settings.
4\. Clone the new (and empty) repository to a local path with a Git client.
5\. Add some commits AND TAGS to the repository and push the changes.
6\. Browse the repository in OpenProject to see the new commits.
7\. Select a Tag from the drop down menu within the Repository view.
8\. Click on any link to a file or folder of the repository.
9\. A message error appears when a link to a folder is clicked, empty page if a link to a file is clicked.
For steps 4 and 5, the commands from attached file “SSH commands to populate Git repository.txt” were used. The link to clone the repository points to a local installation without access from the Internet; modify it accordingly to your own repository.
During steps 6 to 9, screenshots were taken to show the process. Images 01 to 04 show the repository in branch “master” working as intended. Images 05 to 07 show the change to Tag “FSubCommit-a” and the subsequent error.
• Image 01 shows the Repository view in OpenProject, master branch and root directory. The mouse pointer is over the link of directory “sub” within the repository. The link (shown on the status view) will work.
• Images 02 to 04 show the browsing of the repository in the master branch with no errors.
• Image 05 shows the Repository view in OpenProject, master branch and root directory, during the selection of Tag “FSubCommit-a”.
• Image 06 shows the Repository view in OpenProject, Tag “FSubCommit-a” and root directory. The mouse pointer is over the link of directory “sub” within the repository. The link (shown on the status view) will NOT work.
• Image 07 shows the error after clicking on the link of the directory “sub”.
Digging into code, it seems that the parameters “params\[:path\]” and “params\[:rev\]” received by “app/controllers/repositories\_controller.rb”, function “find\_repository”, are not correctly parsed when a Tag is selected in the Repository view. These parameters are stored in “`path” and “`rev” which are then sent to other functions and finally creating the command “git —git-dir /var/db/openproject/git/demo-project.git -c core.quotepath=false ls-tree -l master:revisions/FSubCommit-a/sub” that produces the error because “master:revisions/FSubCommit-a/sub” is not a tree-ish object in Git.
The error has been first found in OpenProject 6.1.5 with a Git repository managed by Gitolite (Git version 2.7.4). It is confirmed in OpenProject 7.3.0 (Git version 2.16.1) and OpenProject 7.4.1 (Git version 2.7.4) with repositories managed by OpenProject.
How to replicate the error:
1\. Install OpenProject (packed installation or manual) with managed Git repositories.
2\. Create a new project and enable the module Repository in the project settings.
3\. Create a new (empty) Git repository for the project in the project settings.
4\. Clone the new (and empty) repository to a local path with a Git client.
5\. Add some commits AND TAGS to the repository and push the changes.
6\. Browse the repository in OpenProject to see the new commits.
7\. Select a Tag from the drop down menu within the Repository view.
8\. Click on any link to a file or folder of the repository.
9\. A message error appears when a link to a folder is clicked, empty page if a link to a file is clicked.
For steps 4 and 5, the commands from attached file “SSH commands to populate Git repository.txt” were used. The link to clone the repository points to a local installation without access from the Internet; modify it accordingly to your own repository.
During steps 6 to 9, screenshots were taken to show the process. Images 01 to 04 show the repository in branch “master” working as intended. Images 05 to 07 show the change to Tag “FSubCommit-a” and the subsequent error.
• Image 01 shows the Repository view in OpenProject, master branch and root directory. The mouse pointer is over the link of directory “sub” within the repository. The link (shown on the status view) will work.
• Images 02 to 04 show the browsing of the repository in the master branch with no errors.
• Image 05 shows the Repository view in OpenProject, master branch and root directory, during the selection of Tag “FSubCommit-a”.
• Image 06 shows the Repository view in OpenProject, Tag “FSubCommit-a” and root directory. The mouse pointer is over the link of directory “sub” within the repository. The link (shown on the status view) will NOT work.
• Image 07 shows the error after clicking on the link of the directory “sub”.
Digging into code, it seems that the parameters “params\[:path\]” and “params\[:rev\]” received by “app/controllers/repositories\_controller.rb”, function “find\_repository”, are not correctly parsed when a Tag is selected in the Repository view. These parameters are stored in “`path” and “`rev” which are then sent to other functions and finally creating the command “git —git-dir /var/db/openproject/git/demo-project.git -c core.quotepath=false ls-tree -l master:revisions/FSubCommit-a/sub” that produces the error because “master:revisions/FSubCommit-a/sub” is not a tree-ish object in Git.