From 307883a5eb582ac203fe0777fcb11fa7d6c3ddca Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 31 Oct 2017 10:18:56 +0000 Subject: get branch name from the DOM --- app/assets/javascripts/repo/index.js | 5 +++-- app/views/shared/repo/_repo.html.haml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/repo/index.js b/app/assets/javascripts/repo/index.js index 480d46eab81..b6801af7fcb 100644 --- a/app/assets/javascripts/repo/index.js +++ b/app/assets/javascripts/repo/index.js @@ -9,6 +9,8 @@ import store from './stores'; import Translate from '../vue_shared/translate'; function initRepo(el) { + if (!el) return null; + return new Vue({ el, store, @@ -38,8 +40,7 @@ function initRepo(el) { onTopOfBranch: convertPermissionToBoolean(data.onTopOfBranch), currentRef: data.ref, path: data.currentPath, - // TODO: get through data attribute - currentBranch: document.querySelector('.js-project-refs-dropdown').dataset.ref, + currentBranch: data.currentBranch, isRoot: convertPermissionToBoolean(data.root), isInitialRoot: convertPermissionToBoolean(data.root), }); diff --git a/app/views/shared/repo/_repo.html.haml b/app/views/shared/repo/_repo.html.haml index c1ba1cfefba..5867ea58378 100644 --- a/app/views/shared/repo/_repo.html.haml +++ b/app/views/shared/repo/_repo.html.haml @@ -1,6 +1,7 @@ #repo{ data: { root: @path.empty?.to_s, root_url: project_tree_path(project), url: content_url, + current_branch: @ref, ref: @commit.id, project_name: project.name, project_url: project_path(project), -- cgit v1.2.1