Skip to content

Commit

Permalink
Framework: Show the commit SHA1 checksum info when we hover the branc…
Browse files Browse the repository at this point in the history
…h name in the environment badge
  • Loading branch information
Tug committed Jan 5, 2016
1 parent f53a865 commit 50503ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/pages/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ html(lang=lang, dir=isRTL ? 'rtl' : 'ltr', class=isFluidWidth ? 'is-fluid-width'
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
span(class=['environment', 'branch-name'], title='Commit ' + commitChecksum)=branchName
if devDocs
span(class=['environment', 'is-docs'])
a(href=devDocsURL title='DevDocs') docs
Expand Down
13 changes: 11 additions & 2 deletions server/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,16 @@ function getChunk( path ) {

function getCurrentBranchName() {
try {
return execSync('git rev-parse --abbrev-ref HEAD');
} catch(err) {
return execSync( 'git rev-parse --abbrev-ref HEAD' ).toString().replace( /\s/gm, '' );
} catch ( err ) {
return undefined;
}
}

function getCurrentCommitShortChecksum() {
try {
return execSync( 'git rev-parse --short HEAD' ).toString().replace( /\s/gm, '' );
} catch ( err ) {
return undefined;
}
}
Expand Down Expand Up @@ -168,6 +176,7 @@ function getDefaultContext( request ) {
context.feedbackURL = 'https://github.com/Automattic/wp-calypso/issues/';
context.faviconURL = '/calypso/images/favicons/favicon-development.ico';
context.branchName = getCurrentBranchName();
context.commitChecksum = getCurrentCommitShortChecksum();
}

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

0 comments on commit 50503ab

Please sign in to comment.