Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Display the name of the current branch with the environment badge #1531

Merged
merged 2 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/stylesheets/layout/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,11 @@ body.newdash div.wordpress-com-extension-promo {
background-color: $blue-light;
}
}
&.branch-name {
text-transform: inherit;
background-color: #272727;
color: #F1F1F1;
}
}

.notouch & {
Expand Down
2 changes: 2 additions & 0 deletions server/pages/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ html(lang=lang, dir=isRTL ? 'rtl' : 'ltr', class=isFluidWidth ? 'is-fluid-width'
div.environment-badge
a(class='bug-report', href=feedbackURL, title='Report an issue', target='_blank')
span(class=['environment', 'is-' + badge])=badge
if branchName && branchName !== 'master'
span(class=['environment', 'branch-name'])=branchName
if devDocs
span(class=['environment', 'is-docs'])
a(href=devDocsURL title='DevDocs') docs
Expand Down
10 changes: 10 additions & 0 deletions server/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var express = require( 'express' ),
fs = require( 'fs' ),
crypto = require( 'crypto' ),
qs = require( 'qs' ),
execSync = require( 'child_process' ).execSync,
cookieParser = require( 'cookie-parser' ),
i18nUtils = require( 'lib/i18n-utils' ),
debug = require( 'debug' )( 'calypso:pages' );
Expand Down Expand Up @@ -107,6 +108,14 @@ function getChunk( path ) {
}
}

function getCurrentBranchName() {
try {
return execSync('git rev-parse --abbrev-ref HEAD');
} catch(err) {
return undefined;
}
}

function getDefaultContext( request ) {
var context, chunk;

Expand Down Expand Up @@ -158,6 +167,7 @@ function getDefaultContext( request ) {
context.devDocs = true;
context.feedbackURL = 'https://github.com/Automattic/wp-calypso/issues/new';
context.faviconURL = '/calypso/images/favicons/favicon-development.ico';
context.branchName = getCurrentBranchName();
}

if ( config.isEnabled( 'code-splitting' ) ) {
Expand Down