{"action":"created","issue":{"url":"https://api.github.com/repos/gushphp/gush/issues/401","labels_url":"https://api.github.com/repos/gushphp/gush/issues/401/labels{/name}","comments_url":"https://api.github.com/repos/gushphp/gush/issues/401/comments","events_url":"https://api.github.com/repos/gushphp/gush/issues/401/events","html_url":"https://github.com/gushphp/gush/issues/401","id":66310063,"number":401,"title":"Refactoring ideas","user":{"login":"sstok","id":904790,"avatar_url":"https://avatars.githubusercontent.com/u/904790?v=3","gravatar_id":"","url":"https://api.github.com/users/sstok","html_url":"https://github.com/sstok","followers_url":"https://api.github.com/users/sstok/followers","following_url":"https://api.github.com/users/sstok/following{/other_user}","gists_url":"https://api.github.com/users/sstok/gists{/gist_id}","starred_url":"https://api.github.com/users/sstok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sstok/subscriptions","organizations_url":"https://api.github.com/users/sstok/orgs","repos_url":"https://api.github.com/users/sstok/repos","events_url":"https://api.github.com/users/sstok/events{/privacy}","received_events_url":"https://api.github.com/users/sstok/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gushphp/gush/labels/Feature","name":"Feature","color":"84b6eb"},{"url":"https://api.github.com/repos/gushphp/gush/labels/idea","name":"idea","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-04T11:59:31Z","updated_at":"2015-09-20T09:22:59Z","closed_at":null,"body":"Refactoring ideas\r\n==============\r\n\r\nThis a collection of idea's for refactoring, and not completed yet :dancer: \r\n\r\nAs some require a big changes in the application architecture there is a difference to whats actionable for the next minor release, and what will be done in Gush 2.0.\r\n\r\n## 1.x actionable\r\n\r\n* [ ] ~~Adapt the new Symfony Command Style~~ #402\r\n* [ ] Remove `ProcessHelper::parseProcessArguments()` and require to always use an array for arguments.\r\n* [ ] Detect if cwd is a git repository (only once) (no more caching :+1: )\r\n* [ ] Remove `ProcessHelper::runCommands()` (currently only used in GitHelper::mergeBranch() but should have proper error handling).\r\n* [ ] Move `ProcessHelper::probePhpCsFixer()` to its own service, and redirect output back to the console.\r\n* [ ] The `ProcessHelper` is output-aware for logging, but instead for we can use the `DebugFormatterHelper` is especially designed for this.\r\n* [ ] Always inform which org and repo the user is on like: \"No new issues found in gushphp/gush\".\r\n* [ ] Merge PullRequestPatOnTheBackCommand with `PullRequestMergeCommand` in confirm mode or when 'auto_thanks' is set to true.\r\n* [x] ~~When configuring load all the current values, allow empty password/token when configuring, if there is already a password (ignore) require otherwise.~~ (Skipping Adapters is possible with #413 so this is not needed anymore).\r\n* [x] Show both adapters and issue-trackers in the same list (but mention there support) {1} (#413)\r\n  * `GitHub (Repository & Issue Tracker)`\r\n  * `Jira (Issue Tracker)`\r\n\r\n{1} Unless you use an Enterprise adapter its not really possible to have two separate accounts (and doesn't really make sense either :smile: )\r\n\r\n### Enterprise support (yea!) (depends on #413)\r\n\r\n* Add `ProvidesEnterprise` interface (better naming welcome) for AdapterFactory which adds a `createLocalConfigurator()` method, this method will create a new Configurator that ONLY handles the repository-link information (API address and repository URL) but not authentication (see snippet below for details).\r\n* Adapter repository-link information and authentication is stored in the global gush config, name is calculated by the hashed config (`local gush.yml \"adapter\" value`).\r\n* Configuring (authenticating) is done using the `core:configure` command.\r\n   * Enterprise adapters are hidden (*see them as templates*).\r\n   * Each Enterprise adapter can be used a multiple number of times, so each *configured* enterprise adapter is listed. Configured being, its authenticated.\r\n   * If its not configured its only shown in the list when: you are in a working directory with a local gush file and an Enterprise adapter set as adapter (see snippet).\r\n   * Shown in the same selection list, but displayed as (`GitHub Enterprise on [label] (RepositoryManager, IssueTracker)`)\r\n* To *set* an Enterprise adapter run the `core:init` command, this will display all the adapters and Enterprise adapters, once you choose an Enterprise adapter it will create a new LocalConfigurator for setting the repo-url and api-url. *Because you are in configured working dir `core:configure` will automatically pick-up the configuration for authenticating :+1: *\r\n\r\nlocal gush.yml file\r\n\r\n```yaml\r\nrepo_adapter:\r\n   type: github_enterprise\r\n   label: My company\r\n   config: \r\n     repo_url: ...\r\n     api_url: ...\r\n```\r\n\r\n## 2.0\r\n\r\n*  [ ] Switch to webmozart/console\r\n*  [ ] Determine a Service container (Pimple, Aura.Di, etc.)\r\n*  [ ] Move all none helpers to services\r\n*  [ ] Updating the configuration is a debug detail, we can use Console logger to make this visual when \r\ndebugging is enabled.\r\n*  [x] ~~Use `--org` as remote for git commands, and automatically register and fetch the remote when not present.~~\r\n*  [x] ~~Automatically determine the org (unless set explicitly) for a forked repository; This not possible in 1.x as the Adapter must be available which is not possible at the subscriber.~~\r\n\r\n### Configuration\r\n\r\n*  [ ] Not all adapters use a username for authentication, always ensure a username for each adapter\r\n* ~~Configuration version-schema, when the schema is outdated force a `core:configure` (and provide a loader for to try and load older versions).~~ (DROPPED)\r\n\r\n### Commands\r\n\r\nCommands use the `webmozart/console` package.\r\n\r\nCommands are separated into (for each command) a CommandConfig (definition of the command) and a CommandHandler which handles the actual execution.\r\n\r\n* A CommandHandler receives all mandatory dependencies (Services) in the Constructor.\r\n* A Command handler is created using a Factory, each command is a new object.\r\n* The adapters are provided as service injection, the Factory injects the correct adapter.\r\n\r\n#### Changing commands\r\n\r\nCommands should be threaded like Controllers, they should be slim and all extractable code should be in services (which also makes testing much easier :) )\r\n\r\n* BranchChangelogCommand\r\n* CoreConfigureCommand\r\n* InitCommand (config loading/saving should be handled in a central Configuration service)\r\n* IssueListCommand (issue filtering logic)\r\n* MetaHeaderCommand (determine list of files to update, update the actual files)\r\n* VersionEyeCommand (determine outdated packages, list packages (check), update composer (update), and properly detect dev section which is not case right now!)\r\n\r\n### Adapters\r\n\r\n*  [x] Loading the adapter happens using a Factory\r\n*  [x] Finding the adapter to use is done using a resolver, finding the adapter in the following order:\r\n  * local gush.yml file\r\n  * `--adapter` option (useful when not in a Git folder)\r\n  * Git remote (origin)\r\n  * ~~Global gush config, default adapter.~~ (DROPPED)\r\n* Use a value-object for referencing repositories (instead of using \"org:repo\")\r\n\r\n#### Exception handling\r\n\r\n* Adapters must throw exceptions that make sense and \"not just the raw error message\", only when the error is not handled we should throw an raw API exception.\r\n\r\n#### Enterprise support (yea!)\r\n\r\n* Adapters must be marked with enterprise support (better interface name needed).\r\n* Adapter is only configured when its not in the global gush configuration, name is calculated by the hashed config (`local gush.yml adapter value`).\r\n* Configuring authentication is only possible once its registered (this needs improvement, `gush config --local authentication` ?).\r\n\r\nlocal gush.yml file\r\n\r\n```yaml\r\nrepo_adapter:\r\n   type: github_enterprise\r\n   repo_url: ...\r\n   api_url: ...\r\n```"},"comment":{"url":"https://api.github.com/repos/gushphp/gush/issues/comments/141761198","html_url":"https://github.com/gushphp/gush/issues/401#issuecomment-141761198","issue_url":"https://api.github.com/repos/gushphp/gush/issues/401","id":141761198,"user":{"login":"sstok","id":904790,"avatar_url":"https://avatars.githubusercontent.com/u/904790?v=3","gravatar_id":"","url":"https://api.github.com/users/sstok","html_url":"https://github.com/sstok","followers_url":"https://api.github.com/users/sstok/followers","following_url":"https://api.github.com/users/sstok/following{/other_user}","gists_url":"https://api.github.com/users/sstok/gists{/gist_id}","starred_url":"https://api.github.com/users/sstok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sstok/subscriptions","organizations_url":"https://api.github.com/users/sstok/orgs","repos_url":"https://api.github.com/users/sstok/repos","events_url":"https://api.github.com/users/sstok/events{/privacy}","received_events_url":"https://api.github.com/users/sstok/received_events","type":"User","site_admin":false},"created_at":"2015-09-20T09:22:59Z","updated_at":"2015-09-20T09:22:59Z","body":"I have a rather big idea (*not completed yet*) related to #462\r\n\r\nEach adapter can be configured multiple times, the configuration itself is kept separately (transparent from the commands). \r\n\r\n* Rename 'core:configure' to 'configure:core' and 'core:init' to 'configure:local'\r\n* 'configure:local' configures your local gush configuration.\r\n* If the adapter config-indentifier ('adapter + [no authentication information, eg. repository and API URL]') is already present in the global configuration it's used, else Gush will ask for the authentication credentials.\r\n* For the sake of usability we provide sensible defaults for the repository/API url's.\r\n* 'core:configure' allows to list current adapter configurations, edit/remove them, and allows to add new adapter configurations.\r\n* When you are outside a Gush configured folder Gush will require the `--[issue|repo]-adapter-config` for identifying an adapter configuration, and the `--[issue|repo]-[org|project|repo]` options.\r\n* The git remote-name of a repository is composed as: `[canonical repository-name (eg. github.com-gushphp-gush)` and is generated by the adapter itself (to prevent including unnecessary details like `projects/` or `repositories/`). *resolves #438*\r\n\r\n"}}