/*
HTTP Get

Parameters:
- repo (object): contains github username and repo
- cb (function): callback function
544752
function get (repo, cb) {
    try {
      Gitters.fetch(repo.username + '/' + repo.repo, function(data){
        cb.call(null, repo, data)
      }, /* bubble error */ true)
    } catch(err) {
      log(err.message)
    }
  }
448855
function getRemoteUrl(repo, remote) {
  return wrapPromise(function (resolve, reject) {
    repo.config(function (err, config) {
      if (err) {
        reject(new Error('Failed to find git repository in ' + config.path))
        return
      }

      resolve(config.items['remote.' + remote + '.url'])
    })
  })
}
755424
def getHook(self, repo_user, repo_name, hook_id):
        
        return self.api.makeRequest(
            ['repos', repo_user, repo_name, 'hooks', str(hook_id)],
            method='GET',
            )
822127
function get(url, shouldParse, callback) {
    request(url, function (err, response, body) {
        if (err) {
            console.error('Error making GET request to endpoint ' + url);
      callback(shouldParse ? {} : "{}");
        }

        if (response.statusCode !== 200) {
            console.error('non 200 response for URL: ' + url);
            callback(shouldParse ? {} : "{}");
            return;
        }

        var toReturn = shouldParse ? JSON.parse(body) : body;
        callback(toReturn);
        return;
    });
}
326485
function parseRepoURL(inputUrl) {
  if (!inputUrl) {
    throw new ServerlessError('URL is required');
  }

  const url = URL.parse(inputUrl.replace(/\/$/, ''));

  // check if url parameter is a valid url
  if (!url.host) {
    throw new ServerlessError('The URL you passed is not a valid URL');
  }

  switch (url.hostname) {
    case 'github.com': {
      return parseGitHubURL(url);
    }
    case 'bitbucket.org': {
      return parseBitbucketURL(url);
    }
    case 'gitlab.com': {
      return parseGitlabURL(url);
    }
    default: {
      const msg =
        'The URL you passed is not one of the valid providers: "GitHub", "Bitbucket", or "GitLab".';
      throw new ServerlessError(msg);
    }
  }
}
662405
function getUser (argv, next) {
  if (argv.user) return next()

  const conf = rc('npm')
  if (!conf) return next('no npm config found')

  const github = conf['init.author.github']
  if (!github) return next('no init.author.github set')

  const name = conf['init.author.name']
  if (!name) return next('no init.author.name set')

  argv.user = github
  argv.realName = name
  next()
}
887799
def request_fetch(self, user, repo, request, pull=False, force=False): #pragma: no cover
        '''
        '''
        raise NotImplementedError
125545
function GitHub(ready, user, pass, useSsh) {

  var opts = {
    version: '3.0.0',
    timeout: 30000
  };

  var proxy = bag.proxy();
  if (proxy) {
    proxy = url.parse(proxy);
    opts.proxy = {
      host: proxy.hostname,
      port: proxy.port
    };
  }

  this.gh = new github(opts);
  this.useSsh = useSsh;

  var self = this;
  if (user && pass) {
    // if credentials are provided, use those to authenticate
    self.gh.authenticate({
      type: 'basic',
      username: user,
      password: pass
    });
    // the other branches (oauth and no authentication only call the ready()
    // callback after another callback has resolved, which guarantees that this
    // (constructor) function has returned before the ready callback has been
    // called. This, in turn, ensures that the code calling this constructor has received a constructed object. To ensure this also for the basic auth case, we need to make this asynchronous as well.
    process.nextTick(ready);
  } else {
    var gitHubAuth = new GithubAuth();
    gitHubAuth
      .readAuthToken()
      .then(function success(token) {
        self.gh.authenticate({
          type : 'oauth',
          token : token
        });
        ready();
      }, function error() {
        // no auth token, user did not execute repoman --signin
        // continue without authentication
        ready();
    });
  }
}
214869
def _get_github(self):
        
        from github import Github
        vms("Querying github with user '{}'.".format(self.username))
        g = Github(self.username, self.apikey)
        self._user = g.get_user()
        if self._user is None:
            raise ValueError("Can't authenticate to github with '{}'.".format(self.username))
        #The github user authenticating always has to be specified; however the user
        #may not be able to see the repo, even if it has access to it. We may need
        #to check the organization repos.
        if self.organization is not None:
            self._org = g.get_organization(self.organization)
            vms("Found github organization '{}'.".format(self._org.name), 2)

            #Next we need to find this repository in the lists available to both
            #the user *and* the organization. If they specified an organization, then we
            #should check that first/exclusively.
            for repo in self._org.get_repos():
                if repo.full_name.lower() == self.name.lower():
                    self._repo = repo
                    vms("Found organization repository '{}'.".format(self._repo.full_name), 2)
                    break
        else:
            for repo in self._user.get_repos():
                if repo.full_name.lower() == self.name.lower():
                    self._repo = repo
                    vms("Found user repository '{}'.".format(self._repo.full_name), 2)
                    break
12005
function (cb) {
      async.map(self._repos, function (repo, repoCb) {
        self._client.gitdata.getReference({
          user: self._repoParts[repo].org,
          repo: self._repoParts[repo].repo,
          ref: branchSrcFull
        }, function (err, res) {
          if (self._checkAndHandleError(err, repo, repoCb)) { return; }
          repoCb(null, {
            repo: repo,
            sha: res.object.sha
          });
        });
      }, cb);
    }
1273108
async function getPr(prNo, refreshCache) {
  logger.debug(`getPr(${prNo})`);
  if (!prNo) {
    return null;
  }

  const res = await api.get(
    `./rest/api/1.0/projects/${config.projectKey}/repos/${
      config.repositorySlug
    }/pull-requests/${prNo}`,
    { useCache: !refreshCache }
  );

  const pr = {
    displayNumber: `Pull Request #${res.body.id}`,
    ...utils.prInfo(res.body),
    reviewers: res.body.reviewers.map(r => r.user.name),
  };

  if (pr.state === 'open') {
    const mergeRes = await api.get(
      `./rest/api/1.0/projects/${config.projectKey}/repos/${
        config.repositorySlug
      }/pull-requests/${prNo}/merge`
    );
    pr.isConflicted = !!mergeRes.body.conflicted;
    pr.canMerge = !!mergeRes.body.canMerge;

    const prCommits = (await api.get(
      `./rest/api/1.0/projects/${config.projectKey}/repos/${
        config.repositorySlug
      }/pull-requests/${prNo}/commits?withCounts=true`
    )).body;

    if (prCommits.totalCount === 1) {
      if (global.gitAuthor) {
        const commitAuthorEmail = prCommits.values[0].author.emailAddress;
        if (commitAuthorEmail === global.gitAuthor.email) {
          logger.debug(
            { prNo },
            '1 commit matches configured gitAuthor so can rebase'
          );
          pr.canRebase = true;
        } else {
          logger.debug(
            { prNo },
            '1 commit and not by configured gitAuthor so cannot rebase'
          );
          pr.canRebase = false;
        }
      } else {
        logger.debug(
          { prNo },
          '1 commit and no configured gitAuthor so can rebase'
        );
        pr.canRebase = true;
      }
    } else {
      logger.debug(
        { prNo },
        `${prCommits.totalCount} commits so cannot rebase`
      );
      pr.canRebase = false;
    }
  }

  if (await branchExists(pr.branchName)) {
    res.isStale = await isBranchStale(pr.branchName);
  }

  return pr;
}
859695
def do_http_repo(self, repo):
        '''
        
        '''
        self.abort_on_missing_effective_repo_name(repo, 'http_repo')
        repo_name = self.get_effective_repo_name(repo)
        try:
            self.network.set(repo_name, REPO.TYPE, REPOTYPE.HTTP)
        except UnknownRepoError:
            self.network.define_http_repo(repo_name)
        self.network.active_repo = repo_name
990248
async function json(url, callback, pubSub) {
  // Fritz: What is going on here? Can someone explain?
  if (url.indexOf('hg19') >= 0) {
    await sleep(1);
  }
  // console.log('url:', url);
  return fetchEither(url, callback, 'json', pubSub);
}
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)
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;
      }));
    });
  });
}
606180
function Repo(name, username) {
  this.name = name;
  this.username = username;
  this.isLoaded = Deferred();
  this.isCloned = Deferred();
  this.isClonning = false;
  this.branch = null;
}
1296106
function (cb) {
      async.map(self._repos, function (repo, repoCb) {
        self._client.gitdata.getReference({
          user: self._repoParts[repo].org,
          repo: self._repoParts[repo].repo,
          ref: branchDestFull
        }, function (err, res) {
          // Allow not found.
          if (err && err.code === NOT_FOUND) {
            repoCb(null, {
              repo: repo,
              exists: false,
              sha: null
            });
            return;
          }

          // Real error.
          if (self._checkAndHandleError(err, "branch.getDestRefs - " + repo, repoCb)) {
            return;
          }

          // Error if existing branches are not allowed.
          var sha = res.object.sha;
          if (!self._allowExisting) {
            self._checkAndHandleError(
              new Error("Found existing dest branch in repo: " + repo + " with sha: " + sha),
              null,
              repoCb);
            return;
          }

          // Have an allowed, existing branch.
          repoCb(null, {
            repo: repo,
            exists: true,
            sha: sha
          });
        });
      }, cb);
    }