Skip to content

Commit

Permalink
implement install and big refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Nov 25, 2023
1 parent 960d09b commit bd80284
Show file tree
Hide file tree
Showing 12 changed files with 1,110 additions and 1,074 deletions.
99 changes: 2 additions & 97 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ clap = { version = "4.4.8", features = ["derive"], optional = true }
fs4 = "0.7.0"
pathdiff = "0.2.1"
termcolor = "1.4.0"
termsize = "0.1.6"
thiserror = "1.0.50"
which = "5.0.0"

Expand Down
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![License Badge](https://img.shields.io/github/license/Pistonite/magoo)
![Issue Badge](https://img.shields.io/github/issues/Pistonite/magoo)

**In Development. commands left are: install, update, remove**
**In Development. commands left are: update, remove**

This ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) is Magoo, he helps you manage git submodules with ease, like `npm` or `cargo`, but for submodules.

Expand Down Expand Up @@ -45,15 +45,23 @@ the officially supported `git` versions. Unsupported versions might work as well


### Add a submodule
To add a submodule, ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) needs to know:
- `URL`: The git URL like https://github.com/owner/repo
- `PATH`: The path in your repo the module should be at
- Optionally, `BRANCH`: The branch to update to when you run `magoo update`

The argument for adding a submodule is very similar to [`git submodule add`](https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt)

![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) needs to know the following to add a submodule.:

|Arg|Description|Default|
|-|-|-|
|`URL`| The git URL like `https://github.com/owner/repo`. | URL is Required |
|`PATH`| The path in your repo the module should be at | Directory at the top level with the same name as the submodule repo|
|`BRANCH`| The branch to update to when you run `magoo update` | None (`HEAD`) |
|`NAME`| Name to identify the submodule for other commands | same as `PATH` |

It's recommended to always specify the `BRANCH`. Git by default will use the `HEAD` branch, which
is usually not what you want.

```bash
magoo install URL --branch BRANCH
magoo install URL PATH --branch BRANCH
magoo install URL PATH --branch BRANCH --name NAME --depth DEPTH --force
```
Expand All @@ -64,19 +72,22 @@ Run `magoo install help` to see other options
```bash
magoo install
```
This will ensure the submodules are cloned/updated to the commit stored in the index.
You should run `magoo install` every time you pull - similar to `npm install`.
It also deletes submodules that are deleted by others.
![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) will ensure the submodules are cloned/updated to the commit stored in the index.
You should run `magoo install` every time you pull the changes from others, in case they were updated.
It also deletes submodules that are deleted by others (by running `status --fix --all`, see below).

### Show submodule status
```bash
magoo status
magoo status --fix
magoo status [--all]
magoo status --fix [--all]
```
Shows everything ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) knows about submodules in the current repo.

If you have tinkered with submodules yourself, ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) might not like the state since
there could be inconsistencies. ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) will tell you what he doesn't like, and the `--fix` option will fix those.
The `--fix` option will bring the submodule states back to a consistent state that ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) likes.
The state could be inconsistent if the git files were changed manually or by running
individual `git` commands, or by a remote change.

The `--all` option can potentially find more residues.

### Update submodules

Expand Down
39 changes: 25 additions & 14 deletions README.txtpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TXTPP#include magoo.txt
![License Badge](https://img.shields.io/github/license/Pistonite/magoo)
![Issue Badge](https://img.shields.io/github/issues/Pistonite/magoo)

**In Development. commands left are: install, update, remove**
**In Development. commands left are: update, remove**

TXTPP#tag MAGOO
TXTPP#include magoo.txt
Expand Down Expand Up @@ -69,17 +69,25 @@ the officially supported `git` versions. Unsupported versions might work as well


### Add a submodule

The argument for adding a submodule is very similar to [`git submodule add`](https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt)

TXTPP#tag MAGOO
TXTPP#include magoo.txt
To add a submodule, MAGOO needs to know:
- `URL`: The git URL like https://github.com/owner/repo
- `PATH`: The path in your repo the module should be at
- Optionally, `BRANCH`: The branch to update to when you run `magoo update`
MAGOO needs to know the following to add a submodule.:

|Arg|Description|Default|
|-|-|-|
|`URL`| The git URL like `https://github.com/owner/repo`. | URL is Required |
|`PATH`| The path in your repo the module should be at | Directory at the top level with the same name as the submodule repo|
|`BRANCH`| The branch to update to when you run `magoo update` | None (`HEAD`) |
|`NAME`| Name to identify the submodule for other commands | same as `PATH` |

It's recommended to always specify the `BRANCH`. Git by default will use the `HEAD` branch, which
is usually not what you want.

```bash
magoo install URL --branch BRANCH
magoo install URL PATH --branch BRANCH
magoo install URL PATH --branch BRANCH --name NAME --depth DEPTH --force
```
Expand All @@ -90,25 +98,28 @@ Run `magoo install help` to see other options
```bash
magoo install
```
This will ensure the submodules are cloned/updated to the commit stored in the index.
You should run `magoo install` every time you pull - similar to `npm install`.
It also deletes submodules that are deleted by others.
TXTPP#tag MAGOO
TXTPP#include magoo.txt
MAGOO will ensure the submodules are cloned/updated to the commit stored in the index.
You should run `magoo install` every time you pull the changes from others, in case they were updated.
It also deletes submodules that are deleted by others (by running `status --fix --all`, see below).

### Show submodule status
```bash
magoo status
magoo status --fix
magoo status [--all]
magoo status --fix [--all]
```
TXTPP#tag MAGOO
TXTPP#include magoo.txt
Shows everything MAGOO knows about submodules in the current repo.

TXTPP#tag MAGOO
TXTPP#include magoo.txt
If you have tinkered with submodules yourself, MAGOO might not like the state since
TXTPP#tag MAGOO
TXTPP#include magoo.txt
there could be inconsistencies. MAGOO will tell you what he doesn't like, and the `--fix` option will fix those.
The `--fix` option will bring the submodule states back to a consistent state that MAGOO likes.
The state could be inconsistent if the git files were changed manually or by running
individual `git` commands, or by a remote change.

The `--all` option can potentially find more residues.

### Update submodules
TXTPP#tag MAGOO
Expand Down
Loading

0 comments on commit bd80284

Please sign in to comment.