<commit_before>"use strict";

var Q = require("bluebird");
var util = require("util");
var fs = require("fs");
var url = require("url");
var mkdirp = Q.promisify(require("mkdirp"));
var _ = require("lodash");

var git = require("./git");
var gerrit_ssh = require("./gerrit-ssh");
var logger = require("./logger");
var prompter = require("./prompter");


var gerrit = {};

gerrit.GerritError = function(msg) {
  Error.call(this);
  Error.captureStackTrace(this, gerrit.GerritError);
  this.message = msg;
  if (util.isArray(this.message)) {
    this.message = util.format.apply(null, this.message);
  }
};
util.inherits(gerrit.GerritError, Error);
var GerritError = gerrit.GerritError;

gerrit.remoteConfig = function(remote) {
  requireInRepo();

  remote = remote || "origin";

  var remoteUrl = git.config(util.format("remote.%s.url", remote));

  if (!remoteUrl) {
    throw new GerritError(["Remote named \"%s\" does not exist", remote]);
  }

  if (/:\/\//.test(remoteUrl)) {
    remoteUrl = url.parse(remoteUrl);
  }
  else {
    remoteUrl = url.parse("ssh://" + remoteUrl);
    remoteUrl.pathname = remoteUrl.pathname && remoteUrl.pathname.replace(/^\/:/, "");
  }

  return {
    name: remote,
    host: remoteUrl.hostname,
    port: remoteUrl.port,
    user: remoteUrl.auth,
    project: remoteUrl.pathname
  };<commit_msg>Fix not getting proper project name from remote config<commit_after>"use strict";

var Q = require("bluebird");
var util = require("util");
var fs = require("fs");
var url = require("url");
var mkdirp = Q.promisify(require("mkdirp"));
var _ = require("lodash");

var git = require("./git");
var gerrit_ssh = require("./gerrit-ssh");
var logger = require("./logger");
var prompter = require("./prompter");


var gerrit = {};

gerrit.GerritError = function(msg) {
  Error.call(this);
  Error.captureStackTrace(this, gerrit.GerritError);
  this.message = msg;
  if (util.isArray(this.message)) {
    this.message = util.format.apply(null, this.message);
  }
};
util.inherits(gerrit.GerritError, Error);
var GerritError = gerrit.GerritError;

gerrit.remoteConfig = function(remote) {
  requireInRepo();

  remote = remote || "origin";

  var remoteUrl = git.config(util.format("remote.%s.url", remote));

  if (!remoteUrl) {
    throw new GerritError(["Remote named \"%s\" does not exist", remote]);
  }

  if (/:\/\//.test(remoteUrl)) {
    remoteUrl = url.parse(remoteUrl);
    remoteUrl.pathname = remoteUrl.pathname && remoteUrl.pathname.replace(/^\//, "");
  }
  else {
    remoteUrl = url.parse("ssh://" + remoteUrl);
    remoteUrl.pathname = remoteUrl.pathname && remoteUrl.pathname.replace(/^\/:/, "");
  }

  remoteUrl.pathname = remoteUrl.pathname && remoteUrl.pathname.replace(/\.git$/, "");

  return {
    name: remote,
    host: remoteUrl.hostname,
    port: remoteUrl.port,
    user: remoteUrl.auth,
    project: remoteUrl.pathname
  };
{'fraction_non_alphanumeric': 0.17992358457797847, 'fraction_numerical': 0.0, 'mean_word_length': 3.948453608247423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2702174', 'n_tokens_mistral': 1006, 'n_tokens_neox': 962, 'n_words': 200}