Actions
Defect #40948
closedActiveRecord::ValueTooLong error with git author longer than 255 characters
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
If a Git repository contains a commit where the author is longer than 255 characters, Redmine throws an exception when loading the commits:
ActiveRecord::ValueTooLong: Data too long for column 'committer'
The attached patch against the current trunk fixes this by truncating the author to 255 characters. Note that this is a git patch which contains an update of the test/fixtures/repositories/git_repository.tar.gz
file. This is an update of the existing repository with just a new commit with a long author added:
Only in git_repository/objects: 14
Only in git_repository/objects: 17
Only in git_repository/objects: 80
diff -ru git_repository-1/packed-refs git_repository/packed-refs
--- a/git_repository/packed-refs 2019-04-05 05:04:24.000000000 +0200
+++ b/git_repository/packed-refs 2024-07-08 19:17:46.019881974 +0200
@@ -1,10 +1,10 @@
-# pack-refs with: peeled fully-peeled
+# pack-refs with: peeled fully-peeled sorted
2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 refs/heads/issue-8857
4fc55c43bf3d3dc2efb66145365ddc17639ce81e refs/heads/latin-1-branch-�-01
1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 refs/heads/latin-1-branch-�-02
1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 refs/heads/latin-1-path-encoding
83ca5fd546063a3c7dc2e568ba3355661a9e2b2c refs/heads/master
-83ca5fd546063a3c7dc2e568ba3355661a9e2b2c refs/heads/master-20120212
+1722811bef943a957eaf9339648df234590281d1 refs/heads/master-20120212
67e7792ce20ccae2e4bb73eed09bb397819c8834 refs/heads/test-latin-1
fba357b886984ee71185ad2065e65fc0417d9b92 refs/heads/test_branch
7234cb2750b63f47bff735edc50a1c0a433c2518 refs/tags/tag00.lightweight
The rest of the patch is as follows:
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 9637702abd..b6b3c8336c 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -219,7 +219,7 @@ def save_revision(rev)
:repository => self,
:revision => rev.identifier,
:scmid => rev.scmid,
- :committer => rev.author,
+ :committer => rev.author.truncate(255),
:committed_on => rev.time,
:comments => rev.message,
:parents => parents
diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb
index fee41faac4..70d7950686 100644
--- a/test/functional/repositories_git_controller_test.rb
+++ b/test/functional/repositories_git_controller_test.rb
@@ -28,7 +28,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
- NUM_REV = 28
+ NUM_REV = 29
def setup
super
diff --git a/test/integration/repositories_git_test.rb b/test/integration/repositories_git_test.rb
index 67c61575ca..8a33c356e9 100644
--- a/test/integration/repositories_git_test.rb
+++ b/test/integration/repositories_git_test.rb
@@ -26,7 +26,7 @@ class RepositoriesGitTest < Redmine::IntegrationTest
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
- NUM_REV = 28
+ NUM_REV = 29
def setup
User.current = nil
Files
Actions