mud-git 0.0.post1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mud/__init__.py +18 -0
- mud/app.py +269 -0
- mud/commands.py +27 -0
- mud/config.py +99 -0
- mud/runner.py +500 -0
- mud/settings.py +51 -0
- mud/styles.py +96 -0
- mud/utils.py +126 -0
- mud_git-0.0.post1.dev1.dist-info/LICENSE +21 -0
- mud_git-0.0.post1.dev1.dist-info/METADATA +139 -0
- mud_git-0.0.post1.dev1.dist-info/RECORD +14 -0
- mud_git-0.0.post1.dev1.dist-info/WHEEL +5 -0
- mud_git-0.0.post1.dev1.dist-info/entry_points.txt +2 -0
- mud_git-0.0.post1.dev1.dist-info/top_level.txt +1 -0
mud/utils.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import random
|
|
5
|
+
|
|
6
|
+
from typing import List
|
|
7
|
+
from prettytable import PrettyTable, PLAIN_COLUMNS
|
|
8
|
+
|
|
9
|
+
from mud.settings import *
|
|
10
|
+
from mud.styles import *
|
|
11
|
+
|
|
12
|
+
SETTINGS_FILE_NAME = '.mudsettings'
|
|
13
|
+
CONFIG_FILE_NAME = '.mudconfig'
|
|
14
|
+
|
|
15
|
+
settings: Settings
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def glyphs(key: str) -> str:
|
|
19
|
+
return GLYPHS[key][0 if settings.config['mud'].getboolean('nerd_fonts', fallback=False) else 1]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def info() -> None:
|
|
23
|
+
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
|
24
|
+
colors = TEXT[3:]
|
|
25
|
+
colors.remove(BRIGHT_WHITE)
|
|
26
|
+
m = random.choice(colors)
|
|
27
|
+
u = random.choice(colors)
|
|
28
|
+
d = random.choice(colors)
|
|
29
|
+
print(f' {d}__{RESET}')
|
|
30
|
+
print(f' {m}__ _ {u}__ __{d}___/ /{RESET}')
|
|
31
|
+
print(f' {m}/ \' \\{u}/ // / {d}_ /{RESET}')
|
|
32
|
+
print(f'{m}/_/_/_/{u}\\_,_/{d}\\_,_/ {RESET}')
|
|
33
|
+
print(f'Jasur Sadikov <jasur@sadikoff.com>\nhttps://github.com/jasursadikov/mud')
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def configure() -> None:
|
|
37
|
+
try:
|
|
38
|
+
settings.config['mud']['run_table'] = str(ask('Do you want to see command execution progress in table view? This will limit output content.'))
|
|
39
|
+
settings.config['mud']['run_async'] = str(ask('Do you want to run commands simultaneously for multiple repositories?'))
|
|
40
|
+
settings.config['mud']['nerd_fonts'] = str(ask(f'Do you want to use {BOLD}nerd-fonts{RESET}?'))
|
|
41
|
+
settings.config['mud']['show_borders'] = str(ask(f'Do you want to see borders in table view?'))
|
|
42
|
+
settings.config['mud']['collapse_paths'] = str(ask(f'Do you want to collapse paths, such as directory paths and branches? (ex. {BOLD}feature/name{RESET} -> {BOLD}f/name{RESET}'))
|
|
43
|
+
except KeyboardInterrupt:
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
settings.save()
|
|
47
|
+
print('Your settings are updated!')
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def ask(text: str) -> bool:
|
|
51
|
+
try:
|
|
52
|
+
answer = input(f"{text}? [Y/n]: ").strip().lower()
|
|
53
|
+
if answer in ('y', 'yes', ''):
|
|
54
|
+
return True
|
|
55
|
+
elif answer in ('n', 'no'):
|
|
56
|
+
return False
|
|
57
|
+
else:
|
|
58
|
+
print("Invalid input.")
|
|
59
|
+
return True
|
|
60
|
+
except KeyboardInterrupt:
|
|
61
|
+
exit()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def print_table(table: PrettyTable) -> None:
|
|
65
|
+
width, _ = shutil.get_terminal_size()
|
|
66
|
+
|
|
67
|
+
def get_real_length(string):
|
|
68
|
+
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
|
|
69
|
+
i = 0
|
|
70
|
+
displayed_count = 0
|
|
71
|
+
|
|
72
|
+
while displayed_count < width and i < len(string):
|
|
73
|
+
match = ansi_escape.match(string, i)
|
|
74
|
+
if match:
|
|
75
|
+
i = match.end()
|
|
76
|
+
else:
|
|
77
|
+
displayed_count += 1
|
|
78
|
+
i += 1
|
|
79
|
+
return i
|
|
80
|
+
|
|
81
|
+
rows = table_to_str(table).split('\n')
|
|
82
|
+
for row in rows:
|
|
83
|
+
stripped = row.strip()
|
|
84
|
+
if len(stripped) != 0:
|
|
85
|
+
if len(stripped) > width:
|
|
86
|
+
print(stripped[:get_real_length(stripped)] + RESET)
|
|
87
|
+
else:
|
|
88
|
+
print(stripped)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def table_to_str(table: PrettyTable) -> str:
|
|
92
|
+
table = table.get_string()
|
|
93
|
+
table = '\n'.join(line.lstrip() for line in table.splitlines())
|
|
94
|
+
return table
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def get_table(field_names: List[str]) -> PrettyTable:
|
|
98
|
+
def set_style(item: str) -> str:
|
|
99
|
+
return f'{DIM}{GRAY}{item}{RESET}'
|
|
100
|
+
|
|
101
|
+
borders = settings.config['mud'].getboolean('show_borders', fallback=False)
|
|
102
|
+
table = PrettyTable(border=borders, header=False, style=PLAIN_COLUMNS, align='l')
|
|
103
|
+
if borders:
|
|
104
|
+
table.horizontal_char = set_style('─')
|
|
105
|
+
table.vertical_char = set_style('│')
|
|
106
|
+
table.junction_char = set_style('┼')
|
|
107
|
+
|
|
108
|
+
table.top_junction_char = set_style('┬')
|
|
109
|
+
table.bottom_junction_char = set_style('┴')
|
|
110
|
+
table.left_junction_char = set_style('├')
|
|
111
|
+
table.right_junction_char = set_style('┤')
|
|
112
|
+
|
|
113
|
+
table.top_left_junction_char = set_style('╭')
|
|
114
|
+
table.top_right_junction_char = set_style('╮')
|
|
115
|
+
table.bottom_left_junction_char = set_style('╰')
|
|
116
|
+
table.bottom_right_junction_char = set_style('╯')
|
|
117
|
+
|
|
118
|
+
table.field_names = field_names
|
|
119
|
+
|
|
120
|
+
return table
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def print_error(text: str, code: int = 255, exit: bool = False) -> None:
|
|
124
|
+
print(f'{BKG_RED}{BRIGHT_WHITE}{glyphs("space")}Error {code}{glyphs("space")}{RESET}{RED}{glyphs(")")}{RESET} {text}')
|
|
125
|
+
if exit:
|
|
126
|
+
sys.exit(code)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jasur Sadikov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mud-git
|
|
3
|
+
Version: 0.0.post1.dev1
|
|
4
|
+
Summary: Multi repository git utility. Manage multiple git-repositories simultaneously.
|
|
5
|
+
Author-email: Jasur Sadikov <jasur@sadikoff.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Jasur Sadikov
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/jasursadikov/mud
|
|
29
|
+
Project-URL: Issues, https://github.com/jasursadikov/mud/issues
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.12
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: prettytable
|
|
37
|
+
|
|
38
|
+
# mud
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+

|
|
42
|
+
[](https://github.com/jasursadikov/mud/actions/workflows/test.yaml)
|
|
43
|
+
[](https://github.com/jasursadikov/mud/actions/workflows/publish-pypi.yaml)
|
|
44
|
+
[](https://github.com/jasursadikov/mud/actions/workflows/publish-aur.yaml)
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
mud is a multi-directory git runner which allows you to run git commands in a multiple repositories. It has multiple powerful tools filtering tools and support of aliasing. This tool is not limited to git commands only, you can run any commands as you wish, but this tool was primarily designed to be used with git, so each referenced directory should have `.git`.
|
|
49
|
+
|
|
50
|
+
## Installing
|
|
51
|
+
For PyPI
|
|
52
|
+
```bash
|
|
53
|
+
pip install mud-git
|
|
54
|
+
```
|
|
55
|
+
For Arch Linux
|
|
56
|
+
```bash
|
|
57
|
+
paru -S mud-git
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Getting started
|
|
61
|
+
|
|
62
|
+
1. Run `mud config` to start interactive wizard which help you to set the preferable settings. Check [settings](#settings) section for more. At the end, `.mudsettings` file will appear at your home directory that you can alter in the future.
|
|
63
|
+
2. Locate to your preferable directory with repositories.
|
|
64
|
+
3. Run `mud init` command to create `.mudconfig` file. This file is important to keep references to repositories. All repositories in current dictionary would be included to `.mudconfig`.
|
|
65
|
+
4. Optional: Run [`mud --set-global`](#global-mudconfig) to make current configuration default and reachable from any directory.
|
|
66
|
+
|
|
67
|
+
All entries are stored in `.mudconfig` in TSV format. After making your first entry, you can open `.mudconfig` in a text editor and modify it according to your needs.
|
|
68
|
+
|
|
69
|
+
### Global .mudconfig
|
|
70
|
+
- `mud --set-global` - sets current `.mudconfig` as a global configuration, so it would be used as a fallback configuration to run from any directory.
|
|
71
|
+
|
|
72
|
+
## Using
|
|
73
|
+
|
|
74
|
+
### Commands
|
|
75
|
+
`mud <FILTER> <COMMAND>` will execute bash command across all repositories. To filter repositories check [arguments](#arguments) section.
|
|
76
|
+
|
|
77
|
+
- `mud info`/`mud i` - displays branch divergence and working directory changes.
|
|
78
|
+
- `mud status`/`mud st` - displays working directory changes.
|
|
79
|
+
- `mud log`/`mud l` - displays latest commit message, it's time and it's author.
|
|
80
|
+
- `mud labels`/`mud lb` - displays mud labels across repositories.
|
|
81
|
+
- `mud branch`/`mud br` - displays all branches in repositories.
|
|
82
|
+
- `mud remote-branch`/`mud rbr` - displays all branches in repositories.
|
|
83
|
+
- `mud tags`/`mud t` - displays git tags in repositories.
|
|
84
|
+
|
|
85
|
+
### Arguments
|
|
86
|
+
- `-l=<label>` or `--label=<label>` - includes repositories with provided label.
|
|
87
|
+
- `-nl=<label>` or `--not-label=<label>` - excludes repositories with provided label.
|
|
88
|
+
- `-b=<branch>` or `--branch=<branch>` - includes repositories with provided branch.
|
|
89
|
+
- `-nb=<branch>` or `--not-branch=<branch>` - excludes repositories with provided label.
|
|
90
|
+
- `-c` or `--command` - explicit command argument. Use this whenever you're trying to run a complex command.
|
|
91
|
+
- `-m` or `--modified` - filters out modified repositories.
|
|
92
|
+
- `-d` or `--diverged` - filters repositories with diverged branches.
|
|
93
|
+
- `-t` or `--table` - toggles default table view setting for run.
|
|
94
|
+
- `-a` or `--async` - toggles asynchronous run feature.
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
mud -b=master -d git pull
|
|
100
|
+
# Filters out all repos with master branch and diverged branches and then runs pull command.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Settings
|
|
104
|
+
|
|
105
|
+
Settings are stored in your home directory in `.mudsettings` file.
|
|
106
|
+
|
|
107
|
+
- `run_async = 0/1` - enables asynchronous commands.
|
|
108
|
+
- `run_table = 0/1` - enables asynchronous commands in a table view. Requires `run_async`.
|
|
109
|
+
- `nerd_fonts = 0/1` - use nerd fonts in the output 💅.
|
|
110
|
+
- `show_borders = 0/1` - enables borders in table view.
|
|
111
|
+
- `collapse_paths = 0/1` - simplifies branch name in the branch view.
|
|
112
|
+
- `config_path = /home/user/path/.mudconfig` - this is set up by `mud --set-global` [command](#global-mudconfig).
|
|
113
|
+
|
|
114
|
+
### Aliases
|
|
115
|
+
|
|
116
|
+
You can create your own aliases for commands. To create your own aliases, edit .mudsettings file, `[alias]` section. .mudsettings has the following aliases by default:
|
|
117
|
+
|
|
118
|
+
```ini
|
|
119
|
+
[alias]
|
|
120
|
+
to = git checkout
|
|
121
|
+
fetch = git fetch
|
|
122
|
+
pull = git pull
|
|
123
|
+
push = git push
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Labeling
|
|
127
|
+
|
|
128
|
+
You can modify your .mudconfig file by using following commands:
|
|
129
|
+
|
|
130
|
+
### Adding and labeling repositories
|
|
131
|
+
|
|
132
|
+
- `mud add <label> <path>` - adds path with an optional label.
|
|
133
|
+
- `mud add <path>` - adds path without a label.
|
|
134
|
+
|
|
135
|
+
### Removing labels and repositories
|
|
136
|
+
|
|
137
|
+
- `mud remove <label>` - removes label from all directories.
|
|
138
|
+
- `mud remove <path>` - removes directory with a specified path.
|
|
139
|
+
- `mud remove <label> <path>` - removes label from a directory.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
mud/__init__.py,sha256=pPgF0j7DCIrNqKSsXB13kJMXmEgHs94PZ-BHes50ZPg,295
|
|
2
|
+
mud/app.py,sha256=psY8-X6B1_CIhzRc1BF7PA0tsxuiJIc7fuak8jpx1PU,10922
|
|
3
|
+
mud/commands.py,sha256=wvv59LVcdN8whZINQSO5YxduhZ7UeaO-9eNFcxrgn0s,839
|
|
4
|
+
mud/config.py,sha256=X3cMpUq4Ia3Ki8Aci6S9I99Cv3BmdmV4n_HFAgpXMr0,2892
|
|
5
|
+
mud/runner.py,sha256=_FL2ie6TMCokidrka6xLmzsg7OBImOVxS-U6ZQOxmq8,19294
|
|
6
|
+
mud/settings.py,sha256=_HUlAhVXdEFGvZ5DO4Qjcz-YX-iPQLdV1SDUvF7WBSY,1369
|
|
7
|
+
mud/styles.py,sha256=tc_G1efPXvI4DofVW5Ezro7nwhpMxtyT0Bq9S77L-U8,2593
|
|
8
|
+
mud/utils.py,sha256=dKrVsOGeonK4bdVgC-UDvQmOvp1n3G4F22CQnaGP40E,3760
|
|
9
|
+
mud_git-0.0.post1.dev1.dist-info/LICENSE,sha256=L44W1tszTRVSItTiRuif2F3qNpTqKcoGQZhgG7oF5V8,1070
|
|
10
|
+
mud_git-0.0.post1.dev1.dist-info/METADATA,sha256=aYiaJBZAdAnqzUiiLMpPZjdcrPYfAO9gkAuOa92sGN8,6734
|
|
11
|
+
mud_git-0.0.post1.dev1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
12
|
+
mud_git-0.0.post1.dev1.dist-info/entry_points.txt,sha256=pbvXRHls6BHhfcMCh2bERpilRj1NGaY1sv4a9ZfBgfU,32
|
|
13
|
+
mud_git-0.0.post1.dev1.dist-info/top_level.txt,sha256=Fk1WPmabIIjp7_iZXLYpbAVqiq7lG7TeAHt30AsOKtQ,4
|
|
14
|
+
mud_git-0.0.post1.dev1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mud
|