summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-23 08:21:51 -0700
committerStan Hu <stanhu@gmail.com>2015-09-23 08:56:32 -0700
commit150fb81ef90cba74bf7828e652e052b9ababcdf8 (patch)
treec11fd94cfcb68fa7ad209822ee6e6d13a694b7ed
parent03fd5919a393b8784c601c76c3ed65912f4b522a (diff)
downloadgitlab-ce-150fb81ef90cba74bf7828e652e052b9ababcdf8.tar.gz
Remove git refs used internally by GitLab from network graph
Closes #2702
-rw-r--r--CHANGELOG1
-rw-r--r--app/helpers/graph_helper.rb5
-rw-r--r--spec/helpers/graph_helper_spec.rb16
3 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1cb338f16da..b0540151fce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.0.1
+ - Remove git refs used internally by GitLab from network graph (Stan Hu)
- Improve CI migration procedure and documentation
v 8.0.0
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb
index e1dda20de85..1e372d5631d 100644
--- a/app/helpers/graph_helper.rb
+++ b/app/helpers/graph_helper.rb
@@ -1,7 +1,10 @@
module GraphHelper
def get_refs(repo, commit)
refs = ""
- refs << commit.ref_names(repo).join(' ')
+ # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
+ # so anything leftover is internally used by GitLab
+ commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') }
+ refs << commit_refs.join(' ')
# append note count
refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb
new file mode 100644
index 00000000000..4acf38771b7
--- /dev/null
+++ b/spec/helpers/graph_helper_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe GraphHelper do
+ describe '#get_refs' do
+ let(:project) { create(:project) }
+ let(:commit) { project.commit("master") }
+ let(:graph) { Network::Graph.new(project, 'master', commit, '') }
+
+ it 'filter our refs used by GitLab' do
+ allow(commit).to receive(:ref_names).and_return(['refs/merge-requests/abc', 'master', 'refs/tmp/xyz'])
+ self.instance_variable_set(:@graph, graph)
+ refs = get_refs(project.repository, commit)
+ expect(refs).to eq('master')
+ end
+ end
+end