/* the Details must contain:
owner: the owner of the repo
repo: repoName
branch: the branch name
335805
function createBranchFromMaster(theDetails) {
	const {owner, repo, branch} = theDetails
	return getMasterBranchSHAs(theDetails)
		.then(result => ({
			owner,
			repo,
			ref: `refs/heads/${branch}`,
			sha: result.parentCommitSHA
		}))
		.then(github.gitdata.createReference)
		.then(githubResponse=>({...theDetails, refURL: githubResponse.data.url}))
		.catch(logError)
}
1003834
function (service, name, user) {
  //
  var services = [];
  //
  services['gh'] = 'https://api.github.com/repos/:user/:name/releases';
  services['npm'] = 'http://registry.npmjs.org/:name/latest';
  services['gem'] = 'https://rubygems.org/api/v1/gems/:name.json';
  services['bower'] = 'https://api.github.com/repos/:user/:name/releases';

  var str = services[service].replace(':name', name).replace(':user', user);
  //
  return str;

}
938314
def repo_name
      unless @repo_name
        url = config["remote.#{name}.url"]
        raise GitProcessError.new("There is no #{name} url set up.") if url.nil? or url.empty?
        uri = Addressable::URI.parse(url)
        @repo_name = uri.path.sub(/\.git/, '').sub(/^\//, '')
      end
      @repo_name
    end
776134
def followers(user_name, repo_name, params={})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      normalize! params

      response = get_request("/1.0/repositories/#{user}/#{repo.downcase}/followers/", params)
      return response unless block_given?
      response.each { |el| yield el }
    end
782105
private function resolveBranch($user, $repo, $branch)
    {
        $api = $this->client->api('git_data')->references();
        $params = [$user, $repo, sprintf('heads/%s', $branch)];

        $data = $this->callGitHub([$api, 'show'], $params);
        return $data['object']['sha'] ?? null;
    }
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('/');
}
512599
function fetchRepoREADME (repo) {
  request({
    uri: 'https://api.github.com/repos/' + repo + '/readme',
    headers: _.extend(headers, {

      // Get raw README content
      'Accept': 'application/vnd.github.VERSION.raw'
    })
  },
  function (error, response, body) {
    if (!error && response.statusCode === 200) {
      lintMarkdown(body, repo);
    } else {
      if (response.headers['x-ratelimit-remaining'] === '0') {
        getAuthToken();
      } else {
        console.log('README for https://github.com/' + repo.blue + ' not found.'.red);
        return;
      }
    }
  });
}
204877
def title(self):
        """"""
        if self.event:
            if self.release['name']:
                return u'{0}: {1}'.format(
                    self.repository['full_name'], self.release['name']
                )
        return u'{0} {1}'.format(self.repo_model.name, self.model.tag)
1266174
private RepositoryId getRepository(final String owner, final String name) throws GitHubException {
		RepositoryId repository = null;
		if(StringUtils.isNotBlank(name) && StringUtils.isNotBlank(owner)){
			repository = RepositoryId.create(owner, name);
		}else{
			throw new GitHubException("No GitHub repository (owner and name) configured");
		}
		if (log.isDebugEnabled()){
			log.debug(MessageFormat.format("Using GitHub repository {0}", repository.generateId()));
		}
		return repository;
	}
1005381
function parseTag (tag, repoOwner, imageName, supplyDefaults = true) {
  let sourceTag = tag
  if (!tag && supplyDefaults) {
    sourceTag = 'latest'
  }
  const parts = sourceTag ? sourceTag.split('_') : []
  if (parts.length > 6) {
    // someone has used underscores in their owner/repo/branch name :|
    return parseProblemTag(sourceTag, repoOwner, imageName)
  } else if (parts.length === 0) {
    return [ repoOwner, imageName, undefined, undefined, undefined, undefined ] // allows for upstream filters
  } else if (parts.length === 1) {
    if (sourceTag === 'latest') {
      return [ repoOwner, imageName, 'master', 'latest' ]
    } else {
      return [ repoOwner, imageName, 'master', sourceTag ]
    }
  } else if (parts.length === 2) {
    return [ repoOwner, imageName, 'master', parts[ 0 ], undefined, parts[ 1 ] ]
  } else if (parts.length === 3) {
    return [ repoOwner, imageName, 'master', ...parts ]
  } else if (parts.length === 4) {
    return [ repoOwner, imageName, ...parts ]
  } else if (parts.length === 6) {
    return parts
  }
}
257542
def get_github_hostname_user_repo_from_url(url):
    
    parsed = parse.urlparse(url)
    if parsed.netloc == '':
        # Probably ssh
        host, sep, path = parsed.path.partition(":")
        if "@" in host:
            username, sep, host = host.partition("@")
    else:
        path = parsed.path[1:].rstrip('/')
        host = parsed.netloc
    user, repo = path.split("/", 1)
    return host, user, repo[:-4] if repo.endswith('.git') else repo
121603
def pull_repo(repo_name):
    """"""
    repo = ClonedRepo.objects.get(pk=repo_name)
    repo.pull()
624463
private static JsonPointer perUserPermissionPointer(String repoName, String memberId) {
        return JsonPointer.compile("/repos" + encodeSegment(repoName) +
                                   "/perUserPermissions" + encodeSegment(memberId));
    }
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))
  })
}
507558
protected String getRepositoryName(String repoName) throws RepositoryException
   {
      // To be cloud compliant we need now to ignore the provided repository name (more details in JCR-2138)
      ManageableRepository repo = repositoryService.getCurrentRepository();
      String currentRepositoryName = repo.getConfiguration().getName();
      if (PropertyManager.isDevelopping() && log.isWarnEnabled())
      {
         if (!currentRepositoryName.equals(repoName))
         {
            log.warn("The expected repository was '" + repoName
               + "' but we will use the current repository instead which is '" + currentRepositoryName + "'");
         }
      }
      return currentRepositoryName;
   }
833471
function resolveRepositoryPath(options, owner, repo) {
  let repPath = path.resolve(options.repoRoot, owner, repo);

  if (options.virtualRepos[owner] && options.virtualRepos[owner][repo]) {
    repPath = path.resolve(options.virtualRepos[owner][repo].path);
  }
  return repPath;
}
572537
function guessUserName(repo) {
  // extract the host
  const host = repo.match(/:\/\/([^/]+)/)[1];
  const hostClean = host.replace(/\./g, '_').toUpperCase();
  // e.g. GITHUB_COM_CREDENTIALS
  const envVar = process.env[`${hostClean}_CREDENTIALS`];
  if (envVar) {
    return envVar;
  }
  return process.env.PHOVEA_GITHUB_CREDENTIALS;
}