Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.169
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/gitinfo/dist/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/gitinfo/dist/gitinfo.js
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _fs = _interopRequireDefault(require("fs"));

var _path = _interopRequireDefault(require("path"));

var _ramda = _interopRequireDefault(require("ramda"));

var _utils = require("./utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// @flow

/**
 * @typedef Configuration
 * @property {string} [defaultBranchName] Default branch name to fallback to. Default: throws an error if branch cannot be resolved.
 * @property {string} [gitPath] Path used to resolve .git path. Defaults to `__dirname`.
 */

/**
 * @access public
 * @name createGitinfo
 * @param {Configuration} userConfig
 */
var _default = userConfig => {
  const gitinfo = {};
  const config = Object.assign({}, {
    gitPath: __dirname
  }, userConfig);

  const gitPath = (() => {
    if ((0, _utils.isGitDirectory)(config.gitPath)) {
      return config.gitPath;
    } else {
      return (0, _utils.findGitPath)(config.gitPath);
    }
  })();
  /**
   * @access public
   * @returns GitHub repository URL.
   */


  gitinfo.getGithubUrl = () => {
    return 'https://github.com/' + gitinfo.getUsername() + '/' + gitinfo.getName();
  };
  /**
   * @see http://stackoverflow.com/a/12142066/368691
   * @access public
   * @returns Name of the current branch.
   */


  gitinfo.getBranchName = () => {
    const name = gitPath + '/HEAD';
    /* istanbul ignore next */

    if (!_fs.default.existsSync(name)) {
      throw new Error('Git HEAD ("' + name + '") does not exist.');
    }

    const head = _fs.default.readFileSync(name, {
      encoding: 'utf8'
    });

    const match = head.match(/^ref: refs\/heads\/(.*)$/m);
    const branch = match && match[1];

    if (branch) {
      return branch;
    }

    if (config.defaultBranchName) {
      return config.defaultBranchName;
    }
    /* istanbul ignore next */


    throw new Error('Cannot get the current branch name.');
  };
  /**
   * @access public
   * @returns Remote URL of the current branch.
   */


  gitinfo.getRemoteUrl = () => {
    const branchName = gitinfo.getBranchName();
    const gitConfig = gitinfo.getConfig();
    const branch = gitConfig['branch "' + branchName + '"'] || gitConfig['branch "' + config.defaultBranchName + '"'];
    /* istanbul ignore next */

    if (!branch) {
      throw new Error('Branch ("' + branchName + '") definition does not exist in the config.');
    } else if (!branch.remote) {
      throw new Error('Branch ("' + branchName + '") does not define "remote".');
    }

    const remote = gitConfig['remote "' + branch.remote + '"'];
    /* istanbul ignore next */

    if (!remote) {
      throw new Error('Remote ("' + branch.remote + '") definition does not exist in the config.');
    } else if (!remote.url) {
      throw new Error('Remote ("' + branch.remote + '") does not define "url".');
    }

    return remote.url;
  };
  /**
   * @access public
   * @returns Absolute path to the .git/ directory.
   */


  gitinfo.getGitPath = () => {
    return gitPath;
  };
  /**
   * @access public
   * @returns Username of the repository author.
   */


  gitinfo.getUsername = () => {
    return (0, _utils.parseRemoteOriginUrl)(gitinfo.getRemoteUrl()).username;
  };
  /**
   * @access public
   * @returns Repository name.
   */


  gitinfo.getName = () => {
    return (0, _utils.parseRemoteOriginUrl)(gitinfo.getRemoteUrl()).name;
  };
  /**
   * @access public
   * @returns Commit SHA of the current branch.
   */


  gitinfo.getHeadSha = () => {
    let sha;
    const branch = gitinfo.getBranchName();

    const shaFile = _path.default.join(gitPath, 'refs', 'heads', branch);

    try {
      sha = _fs.default.readFileSync(shaFile, {
        encoding: 'utf8'
      });
    } catch (error) {
      /* istanbul ignore next */
      throw new Error('Cannot read the commit SHA of the current HEAD from the ' + shaFile + '.\n' + error);
    }

    return _ramda.default.trim(sha);
  };
  /**
   * @access public
   * @returns Representation of the .git/config file.
   */


  gitinfo.getConfig = () => {
    return (0, _utils.parseIni)(gitPath + '/config');
  };

  return gitinfo;
};

exports.default = _default;

Youez - 2016 - github.com/yon3zu
LinuXploit