Skip to content

Commit

Permalink
Warn use of deprecated params (closes #29), upgrade mborne/remote-git…
Browse files Browse the repository at this point in the history
…, complete README, improve github, gitlab and gogs support (fix gogs issue relative to token)
  • Loading branch information
mborne committed Dec 1, 2018
1 parent 44e6355 commit 3480f3c
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 65 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ If you rely on gitlab.com, you will probably need to find projects according to
bin/satis-gitlab gitlab-to-config https://gitlab.com $SATIS_GITLAB_TOKEN -vv --users=mborne --orgs=drutopia
```

## Build configuration according to github repositories
## Build configuration according to non-gitlab repositories

github supports allows to perform :
Repository discovery now relies on [mborne/remote-git](https://packagist.org/packages/mborne/remote-git) so that other git hosting services such as github or gogs are supported.

### github

```bash
bin/satis-gitlab gitlab-to-config https://github.com $SATIS_GITHUB_TOKEN --orgs=symfony --users=mborne
Expand All @@ -89,6 +91,14 @@ bin/satis-gitlab build --skip-errors satis.json web

(Note that GITHUB_TOKEN is required to avoid rate request limitation)

### gogs

```bash
bin/satis-gitlab gitlab-to-config https://gogs.mydomain.org $SATIS_GOGS_TOKEN
bin/satis-gitlab build --skip-errors satis.json web
```

(Note that gogs detection is based on hostname)

### Mirror dependencies

Expand Down
86 changes: 43 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 25 additions & 15 deletions src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use MBO\RemoteGit\Filter\RequiredFileFilter;

use MBO\SatisGitlab\GitFilter\GitlabNamespaceFilter;
use MBO\RemoteGit\Gitlab\GitlabClient;
use MBO\RemoteGit\Github\GithubClient;

/**
* Generate SATIS configuration scanning gitlab repositories
Expand Down Expand Up @@ -53,23 +55,23 @@ protected function configure() {
/*
* Git client options
*/
->addArgument('gitlab-url', InputArgument::REQUIRED)
->addArgument('gitlab-token')
->addArgument('git-url', InputArgument::REQUIRED)
->addArgument('git-token')

/*
* Project listing options (hosted git api level)
*/
->addOption('orgs', 'o', InputOption::VALUE_REQUIRED, 'Find projects according to given organization names')
->addOption('users', 'u', InputOption::VALUE_REQUIRED, 'Find projects according to given user names')
->addOption('projectFilter', 'p', InputOption::VALUE_OPTIONAL, 'filter for projects (deprecated : see organization and users)', null)
->addOption('projectFilter', 'p', InputOption::VALUE_OPTIONAL, '[DEPRECATED] filter for projects (deprecated : see organization and users)', null)

/*
* Project filters
*/
->addOption('ignore', 'i', InputOption::VALUE_REQUIRED, 'ignore project according to a regexp, for ex : "(^phpstorm|^typo3\/library)"', null)
->addOption('include-if-has-file',null,InputOption::VALUE_REQUIRED, 'include in satis config if project contains a given file, for ex : ".satisinclude"', null)
->addOption('project-type',null,InputOption::VALUE_REQUIRED, 'include in satis config if project is of a specified type, for ex : "library"', null)
->addOption('gitlab-namespace',null,InputOption::VALUE_REQUIRED, 'include in satis config if gitlab project namespace is in the list, for ex : "2,Diaspora" (deprecated : see organization and users)', null)
->addOption('gitlab-namespace',null,InputOption::VALUE_REQUIRED, '[DEPRECATED] include in satis config if gitlab project namespace is in the list, for ex : "2,Diaspora"', null)
/*
* satis config generation options
*/
Expand Down Expand Up @@ -98,8 +100,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
* Create git client according to parameters
*/
$clientOptions = new ClientOptions();
$clientOptions->setUrl($input->getArgument('gitlab-url'));
$clientOptions->setToken($input->getArgument('gitlab-token'));
$clientOptions->setUrl($input->getArgument('git-url'));
$clientOptions->setToken($input->getArgument('git-token'));
/*
* TODO add option
* see https://github.com/mborne/satis-gitlab/issues/2
Expand Down Expand Up @@ -130,6 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
/* projectFilter option */
$projectFilter = $input->getOption('projectFilter');
if ( ! empty($projectFilter) ) {
$logger->warning(sprintf("--projectFilter is deprecated, prefer --orgs and --users which gives a better control"));
$logger->info(sprintf("Project filter : %s...", $projectFilter));
$findOptions->setSearch($projectFilter);
}
Expand Down Expand Up @@ -173,6 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {

/* gitlab-namespace option */
if ( ! empty($input->getOption('gitlab-namespace')) ){
$logger->warning(sprintf("--gitlab-namespace is deprecated, prefer --orgs to filter groups at gitlab API level"));
$filterCollection->addFilter(new GitlabNamespaceFilter(
$input->getOption('gitlab-namespace')
));
Expand Down Expand Up @@ -201,23 +205,29 @@ protected function execute(InputInterface $input, OutputInterface $output) {
/*
* Register gitlab domain to enable composer gitlab-* authentications
*/
$gitlabDomain = parse_url($clientOptions->getUrl(), PHP_URL_HOST);
$configBuilder->addGitlabDomain($gitlabDomain);
$gitDomain = parse_url($clientOptions->getUrl(), PHP_URL_HOST);
$configBuilder->addGitlabDomain($gitDomain);

if ( ! $input->getOption('no-token') && $clientOptions->hasToken() ){
$configBuilder->addGitlabToken(
$gitlabDomain,
$clientOptions->getToken(),
$clientOptions->isUnsafeSsl()
);
if ( $client instanceof GitlabClient ){
$configBuilder->addGitlabToken(
$gitDomain,
$clientOptions->getToken()
);
}else if ( $client instanceof GithubClient ){
$configBuilder->addGithubToken(
$clientOptions->getToken()
);
}
}

/*
* SCAN gitlab projects to find composer.json file in default branch
*/
$logger->info(sprintf(
"Listing gitlab repositories from %s...",
$clientOptions->getUrl()
"Listing repositories from %s (API : %s)...",
$clientOptions->getUrl(),
$clientOptions->getType()
));

/*
Expand Down
Loading

0 comments on commit 3480f3c

Please sign in to comment.