Evaluate whether GitHub repository is a be package

    Arguments:
        gist (str): username/id pair e.g. mottosso/be-ad
493466
def _repo_is_preset(repo):
    

    package_template = "https://raw.githubusercontent.com"
    package_template += "/{repo}/master/package.json"
    package_path = package_template.format(repo=repo)

    response = get(package_path)
    if response.status_code == 404:
        return False

    try:
        data = response.json()
    except:
        return False

    if not data.get("type") == "bepreset":
        return False

    return True
733620
def get_auth():
    """"""
    import getpass
    user = input("User Name: ")  # noqa
    pswd = getpass.getpass('Password: ')
    return Github(user, pswd)
164788
def _download_gist(self):
        """"""
        parts = parse.urlparse(self.url)
        url = "https://gist.github.com" + parts.path + "/raw"
        return self._download_raw(url)
840650
def github(cls, user, repo):
    
    # For the url format, see: http://maven.apache.org/scm/git.html
    params = dict(user=user, repo=repo)
    connection = 'scm:git:git@github.com:{user}/{repo}.git'.format(**params)
    url = 'https://github.com/{user}/{repo}'.format(**params)
    return cls(connection=connection, developer_connection=connection, url=url)
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
249403
def _remote_github_url_to_string(remote_url):
    """"""
    # TODO: make this work with https URLs
    match = re.search('git@github\.com:(.*)\.git', remote_url)
    if not match:
        raise EnvironmentError('Remote is not a valid github URL')
    identifier = match.group(1)
    return re.sub('\W', ':', identifier)
860648
function GitHubContentAPI(opts) {
  if (!(this instanceof GitHubContentAPI)) return new GitHubContentAPI(opts);

  opts = Object.create(opts || {});

  if (!opts.auth && GITHUB_USERNAME && GITHUB_PASSWORD) opts.auth = GITHUB_USERNAME + ':' + GITHUB_PASSWORD;

  this._host = opts.host || 'https://api.github.com';

  GitHub.call(this, opts);
  Remote.call(this, opts);
  this._gh_request = this.request;
  delete this.request;

  main = this;
}
817088
function fetchAuthors (forPackages, opts) {
  opts = normalizeOpts(opts)
  // start with npmUser and email from registry
  return fetchRegistry(forPackages, {}, opts)
    .then(persons => {
      // reduce duplicates and add pre-known aliases
      return reduceDuplicates(persons, opts)
    })
    .then(persons => {
      // add name, githubUser, and twitter from npm profile
      return fetchProfiles(persons, opts)
    })
    .then(persons => {
      // finish with name and email from github
      return fetchGithub(persons, opts)
    })
}
288023
def validate_repo_url(self, repo: str):
        
        # that should match valid git repos
        if not isinstance(repo, str) or not re.match(r"^(https?|file)://[\w._\-/~]*[.git]?/?$", repo):
            raise ValueError(f"{repo} is not a valid http[s] or file:// git repository.")
129048
def validate_version(self, prefix='v'):
        
        version = self.software_version()
        repo = self.github_repo()
        repo.releases.validate_tag(version, prefix)
        return version
771679
def get_gists(self, since=github.GithubObject.NotSet):
        
        assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
        url_parameters = dict()
        if since is not github.GithubObject.NotSet:
            url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
        return github.PaginatedList.PaginatedList(
            github.Gist.Gist,
            self._requester,
            "/gists",
            url_parameters
        )
919586
def fetch_git(repo, filename, branch="master", hash=None):
    """"""
    url = git_url(repo, filename, branch, hash)
    response = requests.get(url)

    if response.status_code != 200:
        raise Exception('Got a bad status looking up gist.')
    body = response.text
    if not body:
        raise Exception('Unable to get the gist contents.')

    return body
609609
def post_gist(content, description='', filename='file', auth=False):
    """"""
    post_data = json.dumps({
      "description": description,
      "public": True,
      "files": {
        filename: {
          "content": content
        }
      }
    }).encode('utf-8')

    headers = make_auth_header() if auth else {}
    response = requests.post("https://api.github.com/gists", data=post_data, headers=headers)
    response.raise_for_status()
    response_data = json.loads(response.text)
    return response_data['html_url']
819121
def getMyID(self,gist_name):
		'''
		
		'''
		r = requests.get(
			'%s'%BASE_URL+'/users/%s/gists' % self.user,
			headers=self.gist.header
			)
		if (r.status_code == 200):
			r_text = json.loads(r.text)
			limit = len(r.json())

			for g,no in zip(r_text, range(0,limit)):
				for ka,va in r.json()[no]['files'].iteritems():
					if str(va['filename']) == str(gist_name):
						return r.json()[no]['id']
			return 0

		raise Exception('Username not found')
949002
def _input_github_repo(url=None):
    
    if url is None:
        url = user_input('Input the URL of the GitHub repository '
                         'to use as a `trytravis` repository: ')
    url = url.strip()
    http_match = _HTTPS_REGEX.match(url)
    ssh_match = _SSH_REGEX.match(url)
    if not http_match and not ssh_match:
        raise RuntimeError('That URL doesn\'t look like a valid '
                           'GitHub URL. We expect something '
                           'of the form: `https://github.com/[USERNAME]/'
                           '[REPOSITORY]` or `ssh://git@github.com/'
                           '[USERNAME]/[REPOSITORY]')

    # Make sure that the user actually made a new repository on GitHub.
    if http_match:
        _, name = http_match.groups()
    else:
        _, name = ssh_match.groups()
    if 'trytravis' not in name:
        raise RuntimeError('You must have `trytravis` in the name of your '
                           'repository. This is a security feature to reduce '
                           'chances of running git push -f on a repository '
                           'you don\'t mean to.')

    # Make sure that the user actually wants to use this repository.
    accept = user_input('Remember that `trytravis` will make commits on your '
                        'behalf to `%s`. Are you sure you wish to use this '
                        'repository? Type `y` or `yes` to accept: ' % url)
    if accept.lower() not in ['y', 'yes']:
        raise RuntimeError('Operation aborted by user.')

    if not os.path.isdir(config_dir):
        os.makedirs(config_dir)
    with open(os.path.join(config_dir, 'repo'), 'w+') as f:
        f.truncate()
        f.write(url)
    print('Repository saved successfully.')
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)
421091
function _githubOrgRepo (gitUrl) {
  if (!gitUrl) {
    return null
  }
  const match = gitUrl.match(/.*?(:\/\/|@)github\.com[/:](.*?)(#.*?)?$/)
  return match && match[2] && match[2].replace(/\.git$/, '')
}