Post the report to a GitHub Gist and return the URL of the gist.
191532
def post_gist(report_data, old_sha, new_sha):
    """"""
    payload = {
        "description": ("Changes in OpenStack-Ansible between "
                        "{0} and {1}".format(old_sha, new_sha)),
        "public": True,
        "files": {
            "osa-diff-{0}-{1}.rst".format(old_sha, new_sha): {
                "content": report_data
            }
        }
    }
    url = "https://api.github.com/gists"
    r = requests.post(url, data=json.dumps(payload))
    response = r.json()
    return response['html_url']
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']
842732
def GitHub_post(data, url, *, auth, headers):
    
    r = requests.post(url, auth=auth, headers=headers, data=json.dumps(data))
    GitHub_raise_for_status(r)
    return r.json()
193673
def put(self):
        
        content = self.local.read()
        if self.gist:
            self.github.update(self.gist, content)
        else:
            self.github.create(content, public=self.public)
164788
def _download_gist(self):
        """"""
        parts = parse.urlparse(self.url)
        url = "https://gist.github.com" + parts.path + "/raw"
        return self._download_raw(url)
872218
def get_report(self, report_id, **params):
        """"""
        response = self._get('v2', 'reports', report_id, data=params)
        return self._make_api_object(response, Report)
970913
def git_url_ssh_to_https(url):
    
    path = url.split('github.com', 1)[1][1:].strip()
    new = 'https://{GITHUB_TOKEN}@github.com/%s' % path
    print('rewriting git url to: %s' % new)
    return new.format(GITHUB_TOKEN=os.getenv('GITHUB_TOKEN'))
975657
def build_github_url(
    repo,
    branch=None,
    path='requirements.txt',
    token=None
):
    

    repo = re.sub(r"^http(s)?://github.com/", "", repo).strip('/')

    # args come is as 'None' instead of not being provided
    if not path:
        path = 'requirements.txt'

    if not branch:
        branch = get_default_branch(repo)

    url = 'https://raw.githubusercontent.com/{}/{}/{}'.format(
        repo, branch, path
    )

    if token:
        url = '{}?token={}'.format(url, token)

    return url
720262
def get(self):
        """"""
        if self.gist:
            content = self.github.read_gist_file(self.gist)
            self.local.save(content)
1123120
function buildUrl(value, options, file) {
  const [gist] = value.split(/[?#]/);

  const [inlineUsername, id] =
    gist.indexOf("/") > 0 ? gist.split("/") : [null, gist];

  // username can come from inline code or options
  const username = inlineUsername || options.username;

  // checks for a valid username
  if (username == null || username.trim().length === 0) {
    throw new Error("Missing username information");
  }

  // checks for a valid id
  if (id == null || id.trim().length === 0) {
    throw new Error("Missing gist id information");
  }

  // builds the url and completes it with the file if any
  let url = `${baseUrl}/${username}/${id}.json`;
  if (file != null) {
    url += `?file=${file}`;
  }

  return url;
}
406433
function getFileUrl (repo, path, sha, line) {
  var url = "https://github.com/" + repo + "/blob/";

  if (sha) {
    url += sha + "/";
  }

  url += path;

  if (line) {
    url += "#L" + line;
  }

  return url;
}
523098
def store_report_link(backend, user, response, *args, **kwargs):
    '''
    
    '''
    if backend.name is 'lti':
        assignment_pk = response.get('assignment_pk', None)
        assignment = get_object_or_404(Assignment, pk=assignment_pk)
        lti_result, created = LtiResult.objects.get_or_create(assignment=assignment, user=user)
        if created:
            logger.debug("LTI result record not found, creating it.")
        else:
            logger.debug("LTI result record found, updating it.")   # Expected, check LTI standard
        lti_result.lis_result_sourcedid = response.get('lis_result_sourcedid')
        lti_result.lis_outcome_service_url = response.get('lis_outcome_service_url')
        lti_result.save()
728452
def get_github_content(repo,path,auth=None):
	
	request = requests.get(file_url.format(repo=repo, path=path), auth=auth)
	if not request.ok:
		print("There is a problem with the request")
		print(file_url.format(repo=repo, path=path))
		print(request.json())
		exit(1)
	if not request.json()['encoding'] == 'base64':
		raise RuntimeError("Unknown Encoding encountered when fetching {} from repo {}: {}".format(path,repo,request.json()['encoding']))
	return request.json()['content'].decode('base64').decode('utf8')
324134
def push(self):
        
        self.github_repo.create_and_push()
        self._repo = self.github_repo.repo
        return self._repo
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('/');
}
1101573
def post_report(coverage, args):
    """"""
    response = requests.post(URL, files={'json_file': json.dumps(coverage)},
                             verify=(not args.skip_ssl_verify))
    try:
        result = response.json()
    except ValueError:
        result = {'error': 'Failure to submit data. '
                  'Response [%(status)s]: %(text)s' % {
                      'status': response.status_code,
                      'text': response.text}}
    print(result)
    if 'error' in result:
        return result['error']
    return 0
1308665
def post(url, data=None, json=None, **kwargs):
    """"""
    _set_content_type(kwargs)
    if _content_type_is_json(kwargs) and data is not None:
        data = dumps(data)
    _log_request('POST', url, kwargs, data)
    response = requests.post(url, data, json, **kwargs)
    _log_response(response)
    return response