How to use the git-rev-sync.short function in git-rev-sync

To help you get started, we’ve selected a few git-rev-sync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github turt2live / matrix-dimension / src / version.ts View on Github external
import * as git from "git-rev-sync";

let version = "Unknown";
let gitHash = null;

try {
    version = "v" + require("../../package.json").version;
} catch (error) {
    // The log service isn't set up by the time we require this file
    console.error("version", error);
}

try {
    gitHash = git.short();
} catch (error) {
    // The log service isn't set up by the time we require this file
    console.error("version", error);
}

export const CURRENT_VERSION = version + (gitHash ? "-" + gitHash : "");
github mozilla / blurts-server / controllers / dockerflow.js View on Github external
const AppConstants = require("../app-constants");
const mozlog = require("../log");
const {version, homepage} = require("../package.json");


const log = mozlog("controllers.dockerflow");
const versionJsonPath = path.join(__dirname, "..", "version.json");

// If the version.json file already exists (e.g., created by circle + docker),
// don't need to generate it
if (!fs.existsSync(versionJsonPath)) {
  log.info("generating");
  let commit;
  try {
    commit = require("git-rev-sync").short();
  } catch (err) {
    log.error("generating", {err: err});
  }

  const versionJson = {
    commit,
    source: homepage,
    version,
    languages: AppConstants.SUPPORTED_LOCALES,
  };

  fs.writeFileSync(versionJsonPath, JSON.stringify(versionJson, null, 2) + "\n");
}


function vers (req, res) {
github Leaflet / Leaflet.markercluster / build / rollup-config.js View on Github external
import rollupGitVersion from 'rollup-plugin-git-version'
import json from 'rollup-plugin-json'

import gitRev from 'git-rev-sync'


let version = require('../package.json').version;
let release;

// Skip the git branch+rev in the banner when doing a release build
if (process.env.NODE_ENV === 'release') {
	release = true;
} else {
	release = false;
	const branch = gitRev.branch();
	const rev = gitRev.short();
	version += '+' + branch + '.' + rev;
}

const banner = `/*
 * Leaflet.markercluster ` + version + `,
 * Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps.
 * https://github.com/Leaflet/Leaflet.markercluster
 * (c) 2012-2017, Dave Leaver, smartrak
 */`;

export default {
	input: 'src/index.js',
	output: {
		banner,
		file: 'dist/leaflet.markercluster-src.js',
		format: 'umd',
github mozilla / send / build / version_plugin.js View on Github external
const gitRevSync = require('git-rev-sync');
const pkg = require('../package.json');

let commit = 'unknown';

try {
  commit = gitRevSync.short();
} catch (e) {
  console.warn('Error fetching current git commit: ' + e);
}

const version = JSON.stringify({
  commit,
  source: pkg.homepage,
  version: process.env.CIRCLE_TAG || `v${pkg.version}`
});

class VersionPlugin {
  apply(compiler) {
    compiler.hooks.emit.tap('VersionPlugin', compilation => {
      compilation.assets['version.json'] = {
        source() {
          return version;
github topheman / react-es6-redux / common.js View on Github external
function getInfos() {
  const gitActive = projectIsGitManaged();
  const gitRev = require('git-rev-sync');
  const moment = require('moment');
  const pkg = require('./package.json');
  const infos = {
    pkg: pkg,
    today: moment(new Date()).format('DD/MM/YYYY'),
    year: new Date().toISOString().substr(0, 4),
    gitRevisionShort: gitActive ? gitRev.short() : null,
    gitRevisionLong: gitActive ? gitRev.long() : null,
    author: (pkg.author && pkg.author.name) ? pkg.author.name : (pkg.author || null),
    urlToCommit: null
  };
  infos.urlToCommit = gitActive ? _getUrlToCommit(pkg, infos.gitRevisionLong) : null;
  return infos;
}
github okfn / opendatasurvey / census / controllers / admin.js View on Github external
.then(data => {
    try {
      data.gitRev = git.short();
      data.gitBranch = git.branch();
    } catch (err) {
      console.log(err.stack);
    }
    return data;
  })
  .then(data => {
github topheman / vanilla-es6-jspm / gulp / const.js View on Github external
'use strict';

import util from 'gulp-util';
import moment from 'moment';
import pkg from '../package.json';
import gitRev from 'git-rev-sync';

var infos = {
  file: '',
  pkg: pkg,
  today: moment(new Date()).format('DD/MM/YYYY'),
  year: new Date().toISOString().substr(0, 4),
  gitRevisionShort: gitRev.short(),
  gitRevisionLong: gitRev.long(),
  urlToCommit: null
};

//retrieve and reformat repo url from package.json
if (typeof(pkg.repository) === 'string') {
  infos.urlToCommit = pkg.repository;
}
else if (typeof(pkg.repository.url) === 'string') {
  infos.urlToCommit = pkg.repository.url;
}
//check that there is a git repo specified in package.json & it is a github one
if (infos.urlToCommit !== null && /^https:\/\/github.com/.test(infos.urlToCommit)) {
  infos.urlToCommit = infos.urlToCommit.replace(/.git$/, '/tree/' + infos.gitRevisionLong);//remove the .git at the end
}
github devilesk / dota-interactive-map / scripts / rev.js View on Github external
files.forEach(function (filePath) {
        var buffer = fs.readFileSync(filePath);
        var hash = git.short();
        var basename = path.basename(filePath);
        var ext = path.extname(basename);
        var filename = basename.slice(0, -path.extname(basename).length);
        var revFilename = filename + '.' + hash + ext;
        var tmpPath = path.join(path.dirname(filePath), revFilename);
        if (ext != '.png' || config.vision_data_image_path.indexOf(filename) !== -1) {
            console.log(basename, revFilename);
            execSync('mv ' + filePath + ' ' + tmpPath);
            execSync("replace " + basename + " " + revFilename + " dist/index.html");
        }
        
        if (ext === '.js') {
            execSync("replace " + basename + ".map " + basename + "." + hash + ".map " + tmpPath);
        }
        
        if (ext === '.map') {

git-rev-sync

Synchronously get the current git commit hash, tag, or branch

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Similar packages