-
Notifications
You must be signed in to change notification settings - Fork 9
T/73: Improve DX and add new commands #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
92f9399
"gitStatusParser()" returns additional property (#anythingToCommit) w…
0f5de51
Improve docs for "gitStatusParser()" function.
b092eb8
Add "commit" command.
3390740
Add "getCommandInstance()" which returns an instance of command which…
54c086f
Improve help screen. Every git command can display its help scren if …
4f840ec
Mgit main file uses new util for loading command.
6b66c64
Improve docs in utils.
03eaced
Upgrade dependencies.
2adc38e
Improve README.
48a7d3f
Remove "--recursive" option from mgit. It is a option for "bootstrap"…
ad9bd3c
Improve documentation, create Command and CommandData types.
a69b19f
Minor changes in naming the variables.
33f8136
Add help screen for all commands.
8e820fe
Checkout command creates new branch (-b option) or read branch name f…
9d7c727
Minor fixes in docs.
c20a482
Add merge command.
96249da
Code style.
f5cf410
Fix validation in merge command.
cb5baba
Rename save-hashes to save and add options: --hash and --branch.
4fd1836
Rename util exec to shell. Fix failed tests of "getOptions" util.
29a4100
Rename save-hashes to save, add option --hash (default) and --branch.
e3d5b32
Add tests for new commands and adjust existing to changes in utils.
c38b4f8
Code style.
a3812ed
New commands: fetch, pull, push.
096f291
CLI core is closed in function now.
f17a9ce
Improve README.
28f7764
Fix istanbul command.
c0eabcb
Revert "Fix istanbul command."
d275835
Fix command name (s/save-hashes/save/).
0b20605
"push" command passes all arguments to git command (the same as "diff").
d7c9092
Removed bootstrap command. Pull does not clone missing repos anymore.…
3ce3a13
Renamed merge to close. Now this command will remove merged branch fr…
b376f55
Aligned README to changes.
28a0781
Fetch command will print log if a repository is up-to-date.
f4368ea
Minor changes in commmand help screen.
b829f31
Minor improvements in the code.
a11080f
Improvements for README.
eab13b9
Sync command prints out directories which are not listed in mgit.json…
52e5dca
Moved stub of fs.lstatSync to the test case.
7afa7c8
Unify a way how to specify params for mgit and git commands. Close co…
50260d3
Close and Commit commands accept message as an option of mgit or git.
7dd9686
"recursive" option of "sync" command now is a mgit option instead of …
560c76a
Improved documentation.
4ce976e
mgit sync#afterExecute will read packages properly.
5c11361
Merge branch 'master' into t/73
8ec819f
Merge branch 'master' into t/73
f20dd9c
Merge branch 'master' into t/73
5e3544f
CC: 100%.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,9 +39,9 @@ First, create a configuration file `mgit.json`: | |
|
|
||
| (Keys of the `dependencies` object are package names and values are repository URLs (GitHub identifiers in this case). Read more about the [`dependencies` option](#the-dependencies-option).) | ||
|
|
||
| And run `mgit bootstrap` to clone all the repositories. By default, they will be cloned to `<cwd>/packages/` directory: | ||
| And run `mgit sync` to clone all the repositories. By default, they will be cloned to `<cwd>/packages/` directory: | ||
|
|
||
| ``` | ||
| ```bash | ||
| packages/ | ||
| ckeditor5-engine/ | ||
| mgit/ | ||
|
|
@@ -52,59 +52,53 @@ packages/ | |
| CLI options: | ||
|
|
||
| ``` | ||
| --recursive Whether to install dependencies recursively. | ||
| Needs to be used together with --repository-include. Only packages | ||
| matching these patterns will be cloned recursively. | ||
| --branch For "save" command: whether to save branch names. | ||
| For "checkout" command: name of branch that would be created. | ||
|
|
||
| Default: false. | ||
| --hash Whether to save current commit hashes. Used only by "save" command. | ||
|
|
||
| --packages Directory to which all repositories will be cloned. | ||
| --ignore Ignores packages which names match the given glob pattern. E.g.: | ||
| > mgit exec --ignore="foo*" "git status" | ||
|
|
||
| Default: '<cwd>/packages/' | ||
| Will ignore all packages which names start from "foo". | ||
| Default: null | ||
|
|
||
| --resolver-path Path to a custom repository resolver function. | ||
| --message Message that will be used as an option for git command. Required for "commit" | ||
| command but it is also used by "close" command (append the message to the default). | ||
|
|
||
| Default: '@mgit2/lib/default-resolver.js'. | ||
| --packages Directory to which all repositories will be cloned or are already installed. | ||
| Default: '<cwd>/packages/' | ||
|
|
||
| --resolver-url-template Template used to generate repository URL out of a | ||
| simplified 'organization/repository' format of the dependencies option. | ||
| --recursive Whether to install dependencies recursively. Used only by "sync" command. | ||
|
|
||
| Default: '[email protected]:${ path }.git'. | ||
| --resolver-path Path to a custom repository resolver function. | ||
| Default: '@mgit2/lib/default-resolver.js' | ||
|
|
||
| --resolver-directory-name Defines how the target directory (where the repository will be cloned) | ||
| is resolved. Supported options are: 'git' (default), 'npm'. | ||
| --resolver-url-template Template used to generate repository URL out of a | ||
| simplified 'organization/repository' format of the dependencies option. | ||
| Default: '[email protected]:${ path }.git'. | ||
|
|
||
| * If 'git' was specified, then the directory name will be extracted from | ||
| the git URL (e.g. for '[email protected]:a/b.git' it will be 'b'). | ||
| * If 'npm' was specified, then the package name will be used as a directory name. | ||
| --resolver-directory-name Defines how the target directory (where the repository will be cloned) | ||
| is resolved. Supported options are: 'git' (default), 'npm'. | ||
|
|
||
| This option can be useful when scoped npm packages are used and one wants to decide | ||
| whether the repository will be cloned to packages/@scope/pkgname' or 'packages/pkgname'. | ||
| * If 'git' was specified, then the directory name will be extracted from | ||
| the git URL (e.g. for '[email protected]:a/b.git' it will be 'b'). | ||
| * If 'npm' was specified, then the package name will be used as a directory name. | ||
|
|
||
| Default: 'git' | ||
| This option can be useful when scoped npm packages are used and one wants to decide | ||
| whether the repository will be cloned to packages/@scope/pkgname' or 'packages/pkgname'. | ||
| Default: 'git' | ||
|
|
||
| --resolver-default-branch The branch name to use if not specified in mgit.json dependencies. | ||
|
|
||
| Default: 'master' | ||
|
|
||
| --ignore Ignores packages which names match the given glob pattern. | ||
|
|
||
| For example: | ||
|
|
||
| > mgit exec --ignore="foo*" "git st" | ||
|
|
||
| Will ignore all packages which names start from "foo". | ||
|
|
||
| Default: null | ||
| Default: master | ||
|
|
||
| --scope Restricts the command to packages which names match the given glob pattern. | ||
|
|
||
| Default: null | ||
| Default: null | ||
| ``` | ||
|
|
||
| All these options can also be specified in `mgit.json` (options passed through CLI takes precedence): | ||
|
|
||
| ```js | ||
| ```json | ||
| { | ||
| "packages": "/workspace/modules", | ||
| "resolverDirectoryName": "npm", | ||
|
|
@@ -163,13 +157,13 @@ const parseRepositoryUrl = require( 'mgit2/lib/utils/parserepositoryurl' ); | |
| * Resolves repository URL for a given package name. | ||
| * | ||
| * @param {String} packageName Package name. | ||
| * @param {Options} data.options The options object. | ||
| * @param {Options} options The options object. | ||
| * @returns {Repository|null} | ||
| */ | ||
| module.exports = function resolver( packageName, options ) { | ||
| // If package name starts with '@ckeditor/ckeditor5-*' clone it from 'ckeditor/ckeditor5-*'. | ||
| if ( packageName.startsWith( '@ckeditor/ckeditor5-' ) ) { | ||
| repositoryUrl = packageName.slice( 1 ); | ||
| const repositoryUrl = packageName.slice( 1 ); | ||
|
|
||
| return parseRepositoryUrl( repositoryUrl ); | ||
| } | ||
|
|
@@ -185,49 +179,77 @@ You can also check the [default resolver](https://github.com/cksource/mgit2/blob | |
|
|
||
| CI servers, such as Travis, can't clone repositories using Git URLs (such as `[email protected]:cksource/mgit.git`). By default, mgit uses Git URLs because it assumes that you'll want to commit to these repositories (and don't want to be asked for a password every time). | ||
|
|
||
| If you need to run mgit on a CI server, then configure it to use HTTP URLs: | ||
| If you need to run mgit on a CI server, then configure it to use HTTPS URLs: | ||
|
|
||
| ```bash | ||
| mgit --resolver-url-template="https://github.com/\${ path }.git" | ||
| ``` | ||
|
|
||
| You can also use full HTTPs URLs to configure `dependencies` in your `mgit.json`. | ||
| You can also use full HTTPS URLs to configure `dependencies` in your `mgit.json`. | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| $ mgit [command] | ||
| ``` | ||
| mgit [command] | ||
|
|
||
| For displaying help screen for specified command, type: | ||
|
|
||
| ```bash | ||
| $ mgit [command] --help | ||
| ``` | ||
|
|
||
| ### bootstrap | ||
| ### sync | ||
|
|
||
| Installs missing packages (i.e. clone them) and check them out to correct branches. | ||
| Updates dependencies. Switches repositories to correct branches (specified in `mgit.json`) and pulls changes. | ||
|
|
||
| This command will not change existing repositories, so you can always safely use it. It's useful to bootstrap the project initially, but later you'll rather want to use `mgit update`. | ||
| If any dependency is missing, the command will install this dependency as well. | ||
|
|
||
| Example: | ||
| This command does not touch repositories in which there are uncommitted changes. | ||
|
|
||
| If in the packages directory will be located some directories that are not specified in `mgit.json`, paths to these directories | ||
| will be printed out on the screen. | ||
|
|
||
| Examples: | ||
|
|
||
| ```bash | ||
| mgit bootstrap --recursive --resolver=path ./dev/custom-repository-resolver.js | ||
| mgit sync --recursive | ||
| ``` | ||
|
|
||
| ### update | ||
| ### pull | ||
|
|
||
| Updates dependencies. Switches repositories to correct branches (specified in `mgit.json`) and pulls changes. | ||
| Pulls changes in existing repositories. It does not change branches in the repositories and pull the changes even if | ||
| the repository contains uncommitted changes. | ||
|
|
||
| If any dependency is missing, the command will install it too. | ||
| Examples: | ||
|
|
||
| This command does not touch repositories in which there are uncommitted changes. | ||
| ```bash | ||
| mgit pull | ||
| ``` | ||
|
|
||
| ### push | ||
|
|
||
| Pushes changes in existing repositories. | ||
|
|
||
| Examples: | ||
|
|
||
| ```bash | ||
| mgit push | ||
| ``` | ||
|
|
||
| ### fetch | ||
|
|
||
| Fetches changes in existing repositories. | ||
|
|
||
| Examples: | ||
|
|
||
| ```bash | ||
| mgit update --recursive | ||
| mgit fetch | ||
| ``` | ||
|
|
||
| ### exec | ||
|
|
||
| For every cloned repository executes the specified shell command. | ||
| Executes specified shell command in existing repositories. | ||
|
|
||
| Example: | ||
|
|
||
|
|
@@ -246,14 +268,53 @@ mgit exec 'echo `pwd`' | |
| # /home/mgit/packages/organization/repository-2 | ||
| ``` | ||
|
|
||
| ### save-hashes | ||
| ### commit (alias: `ci`) | ||
|
|
||
| For every repository that contains changes which can be committed, makes a commit with these files. | ||
| You need to specify the message for the commit. | ||
|
|
||
| Example: | ||
|
|
||
| ```bash | ||
| mgit commit --message 'Introduce PULL_REQUEST_TEMPLATE.md.' | ||
|
|
||
| # Executes `git commit --message 'Introduce PULL_REQUEST_TEMPLATE.md.'` command on each repository. | ||
| # Commit will be made in repositories that "git status" returns a list if changed files (these files must be tracked by Git). | ||
| ``` | ||
|
|
||
| ### close | ||
|
|
||
| Requires a second argument which is a branch name that will be merged to current one. You can also specify the message | ||
| which will be added to the default git-merge message. | ||
|
|
||
| Repositories which do not have specified branch will be ignored. | ||
|
|
||
| After merging, the merged branch will be removed from the remote and the local registry. | ||
|
|
||
| Example: | ||
|
|
||
| ```bash | ||
| # Assumptions: we are on "master" branch and "develop" branch exists. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you used |
||
| mgit merge develop --message 'These changes are required for the future release.' | ||
|
|
||
| # Branch "develop" will be merged into "master". | ||
| # Branch "develop" will be removed from the origin. | ||
| ``` | ||
|
|
||
| ### save | ||
|
|
||
| Saves hashes of packages in `mgit.json`. It allows to easily fix project to a specific state. | ||
|
|
||
| Example: | ||
|
|
||
| ```bash | ||
| mgit save-hashes | ||
| mgit save | ||
| ``` | ||
|
|
||
| If you would like to save name of branches instead of current commit, you can use an option `--branch`: | ||
|
|
||
| ```bash | ||
| mgit save --branch | ||
| ``` | ||
|
|
||
| ### status (alias: `st`) | ||
|
|
@@ -311,14 +372,30 @@ mgit diff -- master...HEAD | |
|
|
||
| ### checkout (alias: `co`) | ||
|
|
||
| Changes branches in repositories according to the configuration file. It does not pull the changes and hance is much faster than `mgit update`. The command is useful for bisecting if your main repository contain a revision log like CKEditor 5's [`master-revision`](https://github.com/ckeditor/ckeditor5/commits/master-revisions) branch. | ||
|
|
||
| Changes branches in repositories according to the configuration file. It does not pull the changes and hance is much faster than `mgit sync`. | ||
| The command is useful for bisecting if your main repository contain a revision log like CKEditor 5's [`master-revision`](https://github.com/ckeditor/ckeditor5/commits/master-revisions) branch. | ||
|
|
||
| ```bash | ||
| mgit checkout | ||
| # or | ||
| mgit co | ||
| ``` | ||
|
|
||
| If specified an argument, specified branch will be used instead of default or saved in `mgit.json` file. | ||
|
|
||
| ```bash | ||
| # Checkout all repositories to "stable" branch. | ||
| mgit checkout stable | ||
| ``` | ||
|
|
||
| Also you can specify the `--branch` option which means that mgit creates a new branches in repositories that contains changes (that could be committed). | ||
| It works on the same terms like `mgit commit`. | ||
|
|
||
| ```bash | ||
| # Create the branch "t/foo" in repositories where "git status" returns a list if changed files (these files must be tracked by Git). | ||
| mgit checkout --branch t/foo | ||
| ``` | ||
|
|
||
| ## Projects using mgit2 | ||
|
|
||
| * [CKEditor 5](https://github.com/ckeditor/ckeditor5) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that we're introducing
mgit closeand most likely removing this command, but I wanted to ask you for a more detailed description whatmgit closewill do.