Skip to content

Commit

Permalink
Remove extraneous newlines in pre-receive hook
Browse files Browse the repository at this point in the history
Found while investigating slow performance in gitlab-org/gitlab-ce#17225

We were adding a newline for every branch push because:

1. GitlabAccess calls changes.lines, which keeps the newline (e.g. ['00000000 12345678 refs/heads/master\n'])
2. GitlabNet calls changes.join("\n"), which adds another newline
  • Loading branch information
stanhu committed May 9, 2016
1 parent 9bf9942 commit 7a70b6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,4 +1,5 @@
v3.0.0
- Remove extraneous newlines in pre-receive hook
- Remove rm-tag command (Robert Schilling)
- Remove create-branch and rm-branch commands (Robert Schilling)
- Update PostReceive worker so it logs a unique JID in Sidekiq
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab_access.rb
Expand Up @@ -16,7 +16,7 @@ def initialize(repo_path, actor, changes)
@repo_path = repo_path.strip
@actor = actor
@repo_name = extract_repo_name(@repo_path.dup, config.repos_path.to_s)
@changes = changes.lines
@changes = changes.split("\n")
end

def exec
Expand Down
4 changes: 2 additions & 2 deletions spec/gitlab_access_spec.rb
Expand Up @@ -11,7 +11,7 @@
end
end
subject do
GitlabAccess.new(repo_path, 'key-123', 'wow').tap do |access|
GitlabAccess.new(repo_path, 'key-123', "first\nsecond\n").tap do |access|
access.stub(exec_cmd: :exec_called)
access.stub(api: api)
end
Expand All @@ -24,7 +24,7 @@
describe :initialize do
it { subject.repo_name.should == repo_name }
it { subject.repo_path.should == repo_path }
it { subject.changes.should == ['wow'] }
it { subject.changes.should == ['first', 'second'] }
end

describe "#exec" do
Expand Down

0 comments on commit 7a70b6d

Please sign in to comment.