Skip to content
Merged
Show file tree
Hide file tree
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…
Aug 10, 2018
0f5de51
Improve docs for "gitStatusParser()" function.
Aug 10, 2018
b092eb8
Add "commit" command.
Aug 10, 2018
3390740
Add "getCommandInstance()" which returns an instance of command which…
Aug 10, 2018
54c086f
Improve help screen. Every git command can display its help scren if …
Aug 10, 2018
4f840ec
Mgit main file uses new util for loading command.
Aug 10, 2018
6b66c64
Improve docs in utils.
Aug 10, 2018
03eaced
Upgrade dependencies.
Aug 10, 2018
2adc38e
Improve README.
Aug 10, 2018
48a7d3f
Remove "--recursive" option from mgit. It is a option for "bootstrap"…
Aug 12, 2018
ad9bd3c
Improve documentation, create Command and CommandData types.
Aug 12, 2018
a69b19f
Minor changes in naming the variables.
Aug 12, 2018
33f8136
Add help screen for all commands.
Aug 12, 2018
8e820fe
Checkout command creates new branch (-b option) or read branch name f…
Aug 13, 2018
9d7c727
Minor fixes in docs.
Aug 13, 2018
c20a482
Add merge command.
Aug 13, 2018
96249da
Code style.
Aug 13, 2018
f5cf410
Fix validation in merge command.
Aug 14, 2018
cb5baba
Rename save-hashes to save and add options: --hash and --branch.
Aug 14, 2018
4fd1836
Rename util exec to shell. Fix failed tests of "getOptions" util.
Aug 14, 2018
29a4100
Rename save-hashes to save, add option --hash (default) and --branch.
Aug 14, 2018
e3d5b32
Add tests for new commands and adjust existing to changes in utils.
Aug 14, 2018
c38b4f8
Code style.
Aug 20, 2018
a3812ed
New commands: fetch, pull, push.
Aug 20, 2018
096f291
CLI core is closed in function now.
Aug 20, 2018
f17a9ce
Improve README.
Aug 20, 2018
28f7764
Fix istanbul command.
Aug 20, 2018
c0eabcb
Revert "Fix istanbul command."
Aug 20, 2018
d275835
Fix command name (s/save-hashes/save/).
Aug 21, 2018
0b20605
"push" command passes all arguments to git command (the same as "diff").
Aug 24, 2018
d7c9092
Removed bootstrap command. Pull does not clone missing repos anymore.…
Sep 10, 2018
3ce3a13
Renamed merge to close. Now this command will remove merged branch fr…
Sep 10, 2018
b376f55
Aligned README to changes.
Sep 10, 2018
28a0781
Fetch command will print log if a repository is up-to-date.
Sep 10, 2018
f4368ea
Minor changes in commmand help screen.
Sep 10, 2018
b829f31
Minor improvements in the code.
Sep 10, 2018
a11080f
Improvements for README.
Sep 10, 2018
eab13b9
Sync command prints out directories which are not listed in mgit.json…
Sep 11, 2018
52e5dca
Moved stub of fs.lstatSync to the test case.
Sep 11, 2018
7afa7c8
Unify a way how to specify params for mgit and git commands. Close co…
Sep 12, 2018
50260d3
Close and Commit commands accept message as an option of mgit or git.
Sep 13, 2018
7dd9686
"recursive" option of "sync" command now is a mgit option instead of …
Sep 13, 2018
560c76a
Improved documentation.
Sep 13, 2018
4ce976e
mgit sync#afterExecute will read packages properly.
Oct 2, 2018
5c11361
Merge branch 'master' into t/73
Nov 19, 2018
8ec819f
Merge branch 'master' into t/73
Nov 23, 2018
f20dd9c
Merge branch 'master' into t/73
Dec 6, 2018
5e3544f
CC: 100%.
Dec 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 133 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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",
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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:

Expand All @@ -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
Copy link
Member

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 close and most likely removing this command, but I wanted to ask you for a more detailed description what mgit close will do.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you used " and below backticks around branch names. Since this is preformatted anyway, I'd go with ".

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`)
Expand Down Expand Up @@ -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)
Loading