Npm's `package.json` 'repository.url' could be set to one of three forms:
git@github.com:<author>/<repo-name>.git
git+https://github.com/<author>/<repo-name>.git
or just <author>/<repo-name>
@returns [<author>, <repo-name>] array
437061
function getOwnerAndRepo(url) {
  let match = url.match(/^git@github\.com:(.*)\.git$/);
  match = match || url.match(/^git\+https:\/\/github\.com\/(.*)\.git$/);
  const gitUrlBase = match && match[1];
  return (gitUrlBase || url).split('/');
}
229016
function () {
  var shrinkWrapPath = path.resolve(process.cwd(), 'npm-shrinkwrap.json');
  if (fs.existsSync(shrinkWrapPath)) {
    logger.logInfo('[npm] using npm-shrinkwrap.json instead of package.json');
    return shrinkWrapPath;
  }

  if (getNpmMajorVersion() >= 5) {
      var packageLockPath = path.resolve(process.cwd(), 'package-lock.json');
      if (fs.existsSync(packageLockPath)) {
          logger.logInfo('[npm] using package-lock.json instead of package.json');
          return packageLockPath;
      }
  }

  var packagePath = path.resolve(process.cwd(), 'package.json');
  return packagePath;
}
1357362
function getPRsForRepo(repo) {
  print(['Fetching PRs for ', clc.yellow.bold(`${repo.owner.login}/${repo.name}`)], debug);
  return new Promise((resolve, reject) => {
    github.pullRequests.getAll({
      user: repo.owner.login,
      repo: repo.name,
      state: 'open'
    }, (err, prs) => {
      if (err) {
        return reject(err);
      }
      return resolve(prs.filter((pr) => {
        return pr && pr.head;
      }));
    });
  });
}
1057097
def to_package(self, repo_url):
        """"""
        return Package(name=self.name, url=repo_url + self.name)
785788
function getAuthor(packageJson) {
	if (Array.isArray(packageJson.authors)) {
		packageJson.authors = packageJson.authors.map(author => {
			if (typeof author === 'string') {
				return getPersonObject(author);
			}

			return getAllStar(author);
		});

		return packageJson.authors ? packageJson.authors : false;
	}

	if (typeof packageJson.author === 'string') {
		return getPersonObject(packageJson.author);
	}

	return packageJson.author ?
		getAllStar(packageJson.author) :
		false;
}
594011
function tag() {
  var v = 'v' + pkg.version;
  var message = 'Release ' + v;

  return gulp.src(["./package.json", "./bower.json"])
    .pipe(git.commit(message))
    .pipe(git.tag(v, message))
    ;
    // .pipe(git.push(remote, branch, {args: '--tags'}))
}
627995
function repo (options, callback) {
  var user = options.user
  var repo = options.repo
  var path = options.path || null
  var branch = options.branch || 'master'
  var token = options.token || null

  if (!user || !repo) {
    return callback(new Error('must specify user, repo'))
  }

  if (path) {
    var contentsUrl = '/repos/' + user + '/' + repo + '/contents/'
    return request({
      url: contentsUrl,
      qs: {
        access_token: token,
        ref: branch
      }
    }, function (err, data) {
      if (err) {
        var msg = 'Error requesting data from ' + contentsUrl + ': ' + err.message
        return callback(new Error(msg))
      }

      var isDir = false
      // assume the extension of the requested file is '.geojson', unless proven otherwise
      var extension = '.geojson'

      data.forEach(function (f) {
        // find out the extension of the file requested by the user
        var filenameArray = f.name.split('.')
        if (path === filenameArray[0]) {
          extension = '.' + filenameArray[1]
        }

        if (f.name === path && f.type === 'dir') isDir = true
      })

      if (isDir) {
        var url = '/repos/' + user + '/' + repo + '/contents/' + path

        return request({
          url: url,
          qs: {
            access_token: token,
            ref: branch
          }
        }, function (err, json) {
          if (err) return callback(err)

          var files = []

          json.forEach(function (file) {
            if (file.name.match(/geojson/)) {
              files.push(file)
            }
          })

          if (files.length) {
            return repoFiles({
              url: 'https://raw.github.com/' + user + '/' + repo + '/' + branch + '/' + path + '/',
              files: files
            }, callback)
          }

          callback(new Error('could not find any geojson files at ' + url))
        })
      }

      var urls = [
        'https://api.github.com/repos/' + user + '/' + repo + '/contents/' + path + extension,
        'https://raw.github.com/' + user + '/' + repo + '/' + branch + '/' + path + extension
      ]

      async.map(urls, function (url, cb) {
        request({
          url: url,
          qs: {
            access_token: token,
            ref: branch
          }
        }, cb)
      }, function (err, files) {
        if (err) return callback(err)

        var file = files[0]
        var json = files[1]
        var name = file.name
        var sha = file.sha
        var geojson = null

        if (json.type && json.type === 'FeatureCollection') {
          json.name = name
          json.sha = sha
          geojson = json
        }

        if (geojson) return callback(null, geojson)
        callback(new Error('could not find any geojson: ' + err.message))
      })
    })
  }

  var url = '/repos/' + user + '/' + repo + '/contents'

  request({
    url: url,
    qs: {
      access_token: token,
      ref: branch
    }
  }, function (err, json) {
    if (err) return callback(err)

    var files = []

    json.forEach(function (file) {
      if (file.name.match(/geojson/)) {
        files.push(file)
      }
    })

    if (files.length) {
      return repoFiles({
        url: 'https://raw.github.com/' + user + '/' + repo + '/' + branch + '/',
        files: files
      }, callback)
    }

    callback(new Error('could not find any geojson files at ' + url))
  })
}
1031349
function getURL( repository ) {
    var repourl;

    if (typeof repository === 'object') {
        repourl = repository.url;
    } else {
        repourl = repository
    };

    return repourl;
}
530739
def parseGithubImportPath(self, path):
		
		parts = path.split("/")

		if len(parts) < 3:
			raise ValueError("Import path %s not in github.com/<project>/<repo> form" % path)

		repo = {}
		repo["prefix"] = "/".join(parts[:3])
		repo["signature"] = {"provider": "github", "username": parts[1], "project": parts[2]}

		return repo
969015
function checkPackageJsonInGit () {
  return exec('git', ['status', '--porcelain', 'package.json'])
    .then(function ([stdout, stderr]) {
      debug('git status --porcelain package.json', 'stdout', stdout, 'stderr', stderr)
      if (stdout.indexOf('package.json') >= 0) {
        throw new Error('package.json has changes!\n' +
          'I would like to add scripts to your package.json, but ' +
          'there are changes that have not been commited yet.\n' +
          'I don\'t want to damage anything, so I\'m not doing anyhting right now. ' +
          'Please commit your package.json')
      }
    })
}
1347780
def repository(name):
    """"""
    user_id = current_user.id
    github = GitHubAPI(user_id=user_id)
    token = github.session_token

    if token:
        repos = github.account.extra_data.get('repos', [])
        repo = next((repo for repo_id, repo in repos.items()
                     if repo.get('full_name') == name), {})
        if not repo:
            abort(403)

        try:
            # NOTE: Here we do not check for repository ownership, since it
            # might have changed even though the user might have made releases
            # in the past.
            repo_instance = Repository.get(user_id=user_id,
                                           github_id=repo['id'],
                                           check_owner=False)
        except RepositoryAccessError:
            abort(403)
        except NoResultFound:
            repo_instance = Repository(name=repo['full_name'],
                                       github_id=repo['id'])

        releases = [
            current_github.release_api_class(r) for r in (
                repo_instance.releases.order_by(db.desc(Release.created)).all()
                if repo_instance.id else []
            )
        ]
        return render_template(
            current_app.config['GITHUB_TEMPLATE_VIEW'],
            repo=repo_instance,
            releases=releases,
            serializer=current_github.record_serializer,
        )

    abort(403)
350401
function () {
        var pkg = require(process.cwd() + '/package.json');
        var licenses = [];
        pkg.licenses.forEach(function (license) {
            licenses.push(license.type);
        });

        return '/*! ' + pkg.name + ' - v' + pkg.version + ' - ' + gutil.date("yyyy-mm-dd") + "\n" +
            (pkg.homepage ? "* " + pkg.homepage + "\n" : "") +
            '* Copyright (c) ' + gutil.date("yyyy") + ' ' + pkg.author.name +
            '; Licensed ' + licenses.join(', ') + ' */\n';
    }
898380
async function getPkgReleases({ lookupName, registryUrls }) {
  const versions = [];
  const dependency = getDependencyParts(lookupName);
  if (!is.nonEmptyArray(registryUrls)) {
    logger.error(`No repositories defined for ${dependency.display}`);
    return null;
  }
  const repositories = registryUrls.map(repository =>
    repository.replace(/\/?$/, '/')
  );
  logger.debug(
    `Found ${repositories.length} repositories for ${dependency.display}`
  );
  const repoForVersions = {};
  for (let i = 0; i < repositories.length; i += 1) {
    const repoUrl = repositories[i];
    logger.debug(
      `Looking up ${dependency.display} in repository #${i} - ${repoUrl}`
    );
    const mavenMetadata = await downloadMavenXml(
      dependency,
      repoUrl,
      'maven-metadata.xml'
    );
    if (mavenMetadata) {
      const newVersions = extractVersions(mavenMetadata).filter(
        version => !versions.includes(version)
      );
      const latestVersion = getLatestVersion(newVersions);
      if (latestVersion) {
        repoForVersions[latestVersion] = repoUrl;
      }
      versions.push(...newVersions);
      logger.debug(`Found ${newVersions.length} new versions for ${dependency.display} in repository ${repoUrl}`); // prettier-ignore
    }
  }

  if (versions.length === 0) {
    logger.info(`No versions found for ${dependency.display} in ${repositories.length} repositories`); // prettier-ignore
    return null;
  }
  logger.debug(`Found ${versions.length} versions for ${dependency.display}`);
  const latestVersion = getLatestVersion(versions);
  const repoUrl = repoForVersions[latestVersion];
  const dependencyInfo = await getDependencyInfo(
    dependency,
    repoUrl,
    latestVersion
  );

  return {
    ...dependency,
    ...dependencyInfo,
    releases: versions.map(v => ({ version: v })),
  };
}
986556
function getEvnAuthor () {
	if (/^@?(\d+)(?:\s+[+-]\d+)?$/.test(process.env.GIT_AUTHOR_DATE)) {
		const time = RegExp.$1 - 0;
		const name = process.env.GIT_AUTHOR_NAME;
		const email = process.env.GIT_AUTHOR_EMAIL;
		if (time && name && email) {
			return {
				name: name,
				email: email,
				time: time,
			};
		}
	}
}
1222420
def get_package(repo_url, pkg_name, timeout=1):
    """"""
    url = repo_url + "/packages/" + pkg_name
    headers = {'accept': 'application/json'}
    resp = requests.get(url, headers=headers, timeout=timeout)
    if resp.status_code == 404:
        return None
    return resp.json()
526760
function encodePackageName(packageName) {
  // Thanks https://github.com/unpkg/npm-http-server/blob/master/modules/RegistryUtils.js
  // for scoped modules help
  let encodedPackageName;
  if (packageName[0] === "@") {
    // For the registry URL, the @ doesn't get URL encoded for some reason
    encodedPackageName = `@${encodeURIComponent(packageName.substring(1))}`;
  } else {
    encodedPackageName = encodeURIComponent(packageName);
  }
  return encodedPackageName;
}
1255981
def list(user_name, repo_name, params={})
      update_and_validate_user_repo_params(user_name, repo_name)
      normalize! params

      response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/components", params)
      return response['values'] unless block_given?
      response['values'].each { |el| yield el }
    end