diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-09-24 07:43:53 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-09-24 07:43:53 +0000 |
commit | 4bf1e85cce80495da11d9ca86d15e8b43fef1141 (patch) | |
tree | 48e82f528830a73310860477cdf62c520f0d4645 | |
parent | a58c6e9a9561ffbb3d16a3a9a45bd90a34735b50 (diff) | |
parent | 150fb81ef90cba74bf7828e652e052b9ababcdf8 (diff) | |
download | gitlab-ce-4bf1e85cce80495da11d9ca86d15e8b43fef1141.tar.gz |
Merge branch 'fix-network-graph-refs' into 'master'
Remove git refs used internally by GitLab from network graph
GitLab 8.0 removed satellites and started using git refs that began with `refs/merge-requests/XXX` and `refs/tmp/XXX`, which showed up in an ugly way in the network graph:
![image](https://gitlab.com/stanhu/gitlab-ce/uploads/150eb7ae5f07f0d4793589b5eac462db/image.png)
Closes #2702
See merge request !1410
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/helpers/graph_helper.rb | 5 | ||||
-rw-r--r-- | spec/helpers/graph_helper_spec.rb | 16 |
3 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 3f16a370a94..3710e8f55bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ v 8.0.2 (unreleased) - Fix LDAP attribute mapping 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 |