baldwin 0.0.1__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.
Potentially problematic release.
This version of baldwin might be problematic. Click here for more details.
- baldwin/__init__.py +2 -0
- baldwin/main.py +143 -0
- baldwin/resources/default_gitattributes.txt +30 -0
- baldwin/resources/default_gitignore.txt +166 -0
- baldwin/resources/prettier.config.json +22 -0
- baldwin/utils.py +67 -0
- baldwin-0.0.1.dist-info/METADATA +134 -0
- baldwin-0.0.1.dist-info/RECORD +10 -0
- baldwin-0.0.1.dist-info/WHEEL +4 -0
- baldwin-0.0.1.dist-info/entry_points.txt +4 -0
baldwin/__init__.py
ADDED
baldwin/main.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
from datetime import UTC, datetime
|
|
2
|
+
from importlib import resources
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from shlex import quote
|
|
5
|
+
from shutil import which
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
import subprocess as sp
|
|
9
|
+
|
|
10
|
+
from binaryornot.check import is_binary
|
|
11
|
+
from git import Actor, Repo
|
|
12
|
+
import click
|
|
13
|
+
|
|
14
|
+
from .utils import format_, get_git_path, get_repo
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
__all__ = ('baldwin_main', 'git')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.group(context_settings={'help_option_names': ('-h', '--help')})
|
|
22
|
+
@click.option('-d', '--debug', help='Enable debug logging.', is_flag=True)
|
|
23
|
+
def baldwin_main(*, debug: bool = False) -> None:
|
|
24
|
+
"""Manage a home directory with Git."""
|
|
25
|
+
os.environ['GIT_DIR'] = str(get_git_path())
|
|
26
|
+
os.environ['GIT_WORK_TREE'] = str(Path.home())
|
|
27
|
+
logging.basicConfig(level=logging.DEBUG if debug else logging.ERROR)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@click.command(context_settings={
|
|
31
|
+
'help_option_names': ('-h', '--help'),
|
|
32
|
+
'ignore_unknown_options': True
|
|
33
|
+
})
|
|
34
|
+
@click.argument('args', nargs=-1, type=click.UNPROCESSED)
|
|
35
|
+
def git(args: tuple[str, ...]) -> None:
|
|
36
|
+
# Pass these arguments because of the hgit shortcut
|
|
37
|
+
cmd = ('git', f'--git-dir={get_git_path()}', f'--work-tree={Path.home()}', *args)
|
|
38
|
+
log.debug('Running: %s', ' '.join(quote(x) for x in cmd))
|
|
39
|
+
sp.run(cmd, check=False) # do not use env= because env vars controlling colour will be lost
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
43
|
+
def init() -> None:
|
|
44
|
+
"""Start tracking a home directory."""
|
|
45
|
+
git_path = get_git_path()
|
|
46
|
+
if not git_path.exists():
|
|
47
|
+
repo = Repo.init(git_path, expand_vars=False)
|
|
48
|
+
repo.git.execute(('git', 'config', 'commit.gpgsign', 'false'))
|
|
49
|
+
gitattributes = Path.home() / '.gitattributes'
|
|
50
|
+
gitattributes.write_text(
|
|
51
|
+
resources.read_text('baldwin.resources', 'default_gitattributes.txt'))
|
|
52
|
+
gitignore = Path.home() / '.gitignore'
|
|
53
|
+
gitignore.write_text(resources.read_text('baldwin.resources', 'default_gitignore.txt'))
|
|
54
|
+
repo.index.add([gitattributes, gitignore])
|
|
55
|
+
if which('jq'):
|
|
56
|
+
repo.git.execute(('git', 'config', 'diff.json.textconv', 'jq -MS .'))
|
|
57
|
+
repo.git.execute(('git', 'config', 'diff.json.cachetextconv', 'true'))
|
|
58
|
+
if (prettier := which('prettier')):
|
|
59
|
+
node_modules_path = (Path(prettier).resolve(strict=True).parent / '..' /
|
|
60
|
+
'..').resolve(strict=True)
|
|
61
|
+
if (node_modules_path / '@prettier/plugin-xml/src/plugin.js').exists():
|
|
62
|
+
repo.git.execute(
|
|
63
|
+
('git', 'config', 'diff.xml.textconv',
|
|
64
|
+
'prettier --no-editorconfig --parser xml --xml-whitespace-sensitivity ignore'))
|
|
65
|
+
repo.git.execute(('git', 'config', 'diff.xml.cachetextconv', 'true'))
|
|
66
|
+
repo.git.execute(
|
|
67
|
+
('git', 'config', 'diff.yaml.textconv', 'prettier --no-editorconfig --parser yaml'))
|
|
68
|
+
repo.git.execute(('git', 'config', 'diff.yaml.cachetextconv', 'true'))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
72
|
+
def auto_commit() -> None:
|
|
73
|
+
"""Automatic commit of changed and untracked files."""
|
|
74
|
+
repo = get_repo()
|
|
75
|
+
items_to_add = [
|
|
76
|
+
*[Path.home() / e.a_path for e in repo.index.diff(None)], *[
|
|
77
|
+
x for x in (Path.home() / y
|
|
78
|
+
for y in repo.untracked_files) if x.is_file() and not is_binary(str(x))
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
format_(items_to_add)
|
|
82
|
+
repo.index.add(items_to_add)
|
|
83
|
+
repo.index.commit(f'Automatic commit @ {datetime.now(tz=UTC).isoformat()}',
|
|
84
|
+
committer=Actor('Auto-commiter', 'hgit@tat.sh'))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
88
|
+
def format_main() -> None:
|
|
89
|
+
"""Format changed and untracked files."""
|
|
90
|
+
repo = get_repo()
|
|
91
|
+
format_(
|
|
92
|
+
(*(Path.home() / d.a_path for d in repo.index.diff(None)),
|
|
93
|
+
*(x for x in (Path.home() / y
|
|
94
|
+
for y in repo.untracked_files) if x.is_file() and not is_binary(str(x)))))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
98
|
+
def info() -> None:
|
|
99
|
+
"""Get basic information about the repository."""
|
|
100
|
+
click.echo(f'git-dir path: {get_git_path()}')
|
|
101
|
+
click.echo(f'work-tree path: {Path.home()}')
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
105
|
+
def install_units() -> None:
|
|
106
|
+
"""Install systemd units for automatic committing."""
|
|
107
|
+
bw = which('bw')
|
|
108
|
+
assert bw is not None
|
|
109
|
+
bw_p = Path(bw).resolve(strict=True)
|
|
110
|
+
service_file = Path('~/.config/systemd/user/home-vcs.service').expanduser()
|
|
111
|
+
service_file.write_text(f"""[Unit]
|
|
112
|
+
Description=Home directory VCS commit
|
|
113
|
+
|
|
114
|
+
[Service]
|
|
115
|
+
Type=oneshot
|
|
116
|
+
ExecStart={bw_p} auto-commit
|
|
117
|
+
""")
|
|
118
|
+
log.debug('Wrote to `%s`.', service_file)
|
|
119
|
+
timer_file = Path('~/.config/systemd/user/home-vcs.timer').expanduser()
|
|
120
|
+
timer_file.write_text("""[Unit]
|
|
121
|
+
Description=Hexahourly trigger for Home directory VCS
|
|
122
|
+
|
|
123
|
+
[Timer]
|
|
124
|
+
OnCalendar=0/6:0:00
|
|
125
|
+
|
|
126
|
+
[Install]
|
|
127
|
+
WantedBy=timers.target
|
|
128
|
+
""")
|
|
129
|
+
log.debug('Wrote to `%s`.', timer_file)
|
|
130
|
+
cmd: tuple[str, ...] = ('systemctl', '--user', 'enable', '--now', 'home-vcs.timer')
|
|
131
|
+
log.debug('Running: %s', ' '.join(quote(x) for x in cmd))
|
|
132
|
+
sp.run(cmd, check=True)
|
|
133
|
+
cmd = ('systemctl', '--user', 'daemon-reload')
|
|
134
|
+
log.debug('Running: %s', ' '.join(quote(x) for x in cmd))
|
|
135
|
+
sp.run(('systemctl', '--user', 'daemon-reload'), check=True)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
baldwin_main.add_command(auto_commit, 'auto-commit')
|
|
139
|
+
baldwin_main.add_command(format_main, 'format')
|
|
140
|
+
baldwin_main.add_command(git)
|
|
141
|
+
baldwin_main.add_command(info)
|
|
142
|
+
baldwin_main.add_command(init)
|
|
143
|
+
baldwin_main.add_command(install_units)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
*.json diff=json
|
|
2
|
+
*.knsregistry diff=xml
|
|
3
|
+
*.rdf diff=xml
|
|
4
|
+
*.sgrd diff=xml
|
|
5
|
+
*.xml diff=xml
|
|
6
|
+
*.xml-prev diff=xml
|
|
7
|
+
*.yaml diff=yaml
|
|
8
|
+
*.yml diff=yaml
|
|
9
|
+
.charles.config diff=xml
|
|
10
|
+
.config/**/Bookmarks diff=json
|
|
11
|
+
.config/**/Local*State diff=json
|
|
12
|
+
.config/**/Network*State diff=json
|
|
13
|
+
.config/**/Preferences diff=json
|
|
14
|
+
.config/**/Secure*Preferences diff=json
|
|
15
|
+
.config/**/TransportSecurity diff=json
|
|
16
|
+
.config/fontconfig/conf.*/*.conf diff=xml
|
|
17
|
+
.config/libreoffice/**/*.so* diff=xml
|
|
18
|
+
.config/libreoffice/**/*.xba diff=xml
|
|
19
|
+
.config/libreoffice/**/*.xcu diff=xml
|
|
20
|
+
.config/libreoffice/**/*.xl* diff=xml
|
|
21
|
+
.config/menus/applications-merged/**/*.menu diff=xml
|
|
22
|
+
.config/skypeforlinux/**/*.conf diff=json
|
|
23
|
+
.config/skypeforlinux/SkypeRT/ul.conf diff=txt
|
|
24
|
+
.config/unity3d/**/prefs diff=xml
|
|
25
|
+
.config/unity3d/global.prefs diff=xml
|
|
26
|
+
.designer/**/*.br diff=xml
|
|
27
|
+
.local/share/DBeaverData/**/*.xmi diff=xml
|
|
28
|
+
.local/share/DBeaverData/**/.project diff=xml
|
|
29
|
+
.local/share/kxmlgui5/**/*.rc diff=xml
|
|
30
|
+
.mozilla/firefox/**/sessionstore.js diff=json
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
|
|
2
|
+
!/.dosbox/*.conf
|
|
3
|
+
!/.eclipse/org.jkiss.dbeaver.product*/config.ini
|
|
4
|
+
!/.vscode/argv.json
|
|
5
|
+
!/.vscode/extensions/.init-default-profile-extensions
|
|
6
|
+
!/.vscode/extensions/.obsolete
|
|
7
|
+
!/.vscode/extensions/extensions.json
|
|
8
|
+
*-shm
|
|
9
|
+
*-wal
|
|
10
|
+
*.DLL
|
|
11
|
+
*.EXE
|
|
12
|
+
*.apk
|
|
13
|
+
*.bak
|
|
14
|
+
*.bdic
|
|
15
|
+
*.bin
|
|
16
|
+
*.bmp
|
|
17
|
+
*.corrupt
|
|
18
|
+
*.db
|
|
19
|
+
*.dll
|
|
20
|
+
*.dylib
|
|
21
|
+
*.egg
|
|
22
|
+
*.exe
|
|
23
|
+
*.gif
|
|
24
|
+
*.ics
|
|
25
|
+
*.jar
|
|
26
|
+
*.jsonlz4
|
|
27
|
+
*.kwl
|
|
28
|
+
*.localstorage*
|
|
29
|
+
*.lock
|
|
30
|
+
*.lockfile
|
|
31
|
+
*.log
|
|
32
|
+
*.lz4
|
|
33
|
+
*.mcd
|
|
34
|
+
*.mdf
|
|
35
|
+
*.mscz
|
|
36
|
+
*.msf
|
|
37
|
+
*.odt
|
|
38
|
+
*.old
|
|
39
|
+
*.ovpn
|
|
40
|
+
*.pem
|
|
41
|
+
*.pickle
|
|
42
|
+
*.pid
|
|
43
|
+
*.pmap
|
|
44
|
+
*.pyc
|
|
45
|
+
*.pyd
|
|
46
|
+
*.qch*
|
|
47
|
+
*.qhc
|
|
48
|
+
*.retry
|
|
49
|
+
*.ripdb*
|
|
50
|
+
*.so
|
|
51
|
+
*.sqlite*
|
|
52
|
+
*.sqlite-journal
|
|
53
|
+
*.srm
|
|
54
|
+
*.tar.gz
|
|
55
|
+
*.tga
|
|
56
|
+
*.tmp
|
|
57
|
+
*.ttf
|
|
58
|
+
*.zip
|
|
59
|
+
.directory
|
|
60
|
+
.lock
|
|
61
|
+
.parentlock
|
|
62
|
+
/.F5Networks/*.log
|
|
63
|
+
/.MakeMKV/**/*.svq
|
|
64
|
+
/.MakeMKV/**/*.tgz
|
|
65
|
+
/.MakeMKV/*.tar
|
|
66
|
+
/.Trash-*
|
|
67
|
+
/.VirtualBox/**/*.dat
|
|
68
|
+
/.VirtualBox/**/*.log*
|
|
69
|
+
/.VirtualBox/**/*.xml-prev
|
|
70
|
+
/.VirtualBox/Machines/
|
|
71
|
+
/.acetoneiso/poweriso
|
|
72
|
+
/.android/adb.*
|
|
73
|
+
/.android/adbkey*
|
|
74
|
+
/.android/avd/
|
|
75
|
+
/.android/cache/
|
|
76
|
+
/.android/debug.*
|
|
77
|
+
/.audacity-data/AutoSave/
|
|
78
|
+
/.audacity-data/lastlog.txt
|
|
79
|
+
/.aws/credentials
|
|
80
|
+
/.bitcoin/**/*.dat
|
|
81
|
+
/.bitcoin/**/*lock
|
|
82
|
+
/.bitcoin/blocks/
|
|
83
|
+
/.bitcoin/chainstate/
|
|
84
|
+
/.bitcoin/database/
|
|
85
|
+
/.bitcoin/wallets/
|
|
86
|
+
/.cabal/bin/
|
|
87
|
+
/.cabal/packages/
|
|
88
|
+
/.cabal/store/
|
|
89
|
+
/.cargo/
|
|
90
|
+
/.charles/ca/
|
|
91
|
+
/.charles/certs/
|
|
92
|
+
/.charles/passwords.keystore
|
|
93
|
+
/.cmake/packages/
|
|
94
|
+
/.composer
|
|
95
|
+
/.conan2/extensions/
|
|
96
|
+
/.conan2/p/
|
|
97
|
+
/.conan2/profiles/
|
|
98
|
+
/.conan2/remotes.json
|
|
99
|
+
/.conan2/version.txt
|
|
100
|
+
/.config/**/*.lock
|
|
101
|
+
/.config/**/.org.chromium*
|
|
102
|
+
/.config/**/GPUCache/
|
|
103
|
+
/.config/**/buildid
|
|
104
|
+
/.config/*/*-journal
|
|
105
|
+
/.config/*/Cookies*
|
|
106
|
+
/.config/*/QuotaManager
|
|
107
|
+
/.config/*/SS
|
|
108
|
+
/.config/*/Singleton*
|
|
109
|
+
/.config/*/databases/
|
|
110
|
+
/.config/*cli/history
|
|
111
|
+
/.config/*cli/log
|
|
112
|
+
/.config/Code*/**/meta.json
|
|
113
|
+
/.config/Code*/*Crash Reports/
|
|
114
|
+
/.config/Code*/Backups/
|
|
115
|
+
/.config/Code*/Cache*/
|
|
116
|
+
/.config/Code*/Code Cache/
|
|
117
|
+
/.config/Code*/Cookies*
|
|
118
|
+
/.config/Code*/IndexedDB/
|
|
119
|
+
/.config/Code*/Local Storage/
|
|
120
|
+
/.config/Code*/Network Persistent State
|
|
121
|
+
/.config/Code*/QuotaManager*
|
|
122
|
+
/.config/Code*/Session Storage/
|
|
123
|
+
/.config/Code*/Session Storage/LOG
|
|
124
|
+
/.config/Code*/User/globalStorage/
|
|
125
|
+
/.config/Code*/User/sync/**/20*.json
|
|
126
|
+
/.config/Code*/User/workspaceStorage/
|
|
127
|
+
/.config/Code*/databases/
|
|
128
|
+
/.config/Code*/languagepacks.json
|
|
129
|
+
/.config/Code*/machineid
|
|
130
|
+
/.config/Code*/storage.json
|
|
131
|
+
/.config/Code/Crashpad/
|
|
132
|
+
/.config/Code/DawnCache/
|
|
133
|
+
/.config/Code/DawnGraphiteCache/
|
|
134
|
+
/.config/Code/DawnWebGPUCache/
|
|
135
|
+
/.config/Code/Service Worker/
|
|
136
|
+
/.config/Code/Shared Dictionary/
|
|
137
|
+
/.config/Code/SharedStorage
|
|
138
|
+
/.config/Code/Trust Tokens
|
|
139
|
+
/.config/Code/Trust Tokenss
|
|
140
|
+
/.config/Code/User/History/
|
|
141
|
+
/.config/Code/User/profiles/*/globalStorage/
|
|
142
|
+
/.config/Code/User/sync/
|
|
143
|
+
/.config/Code/WebStorage/
|
|
144
|
+
/.config/Code/fileWatcher/
|
|
145
|
+
/.config/Code/logs/
|
|
146
|
+
/.config/Code/watcherServiceParcelSharedProcess/
|
|
147
|
+
/.config/OpenRCT2/*logs/
|
|
148
|
+
/.config/OpenRCT2/chatlogs/
|
|
149
|
+
/.config/OpenRCT2/object/
|
|
150
|
+
/.config/OpenRCT2/serverlogs/
|
|
151
|
+
/.config/PCSX2/bios/
|
|
152
|
+
/.config/PCSX2/covers/
|
|
153
|
+
/.config/PCSX2/logs/
|
|
154
|
+
/.config/PCSX2/snaps/
|
|
155
|
+
/.config/PCSX2/sstates/*.p2s
|
|
156
|
+
/.config/Ryujinx/bis/
|
|
157
|
+
/.config/Ryujinx/games/
|
|
158
|
+
/.config/Ryujinx/mods/
|
|
159
|
+
/.config/Ryujinx/sdcard/
|
|
160
|
+
/.config/VirtualBox/**.log*
|
|
161
|
+
/.viminfo
|
|
162
|
+
/Desktop/
|
|
163
|
+
/Documents/
|
|
164
|
+
/Downloads/
|
|
165
|
+
/go/
|
|
166
|
+
node_modules
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"endOfLine": "lf",
|
|
3
|
+
"iniSpaceAroundEquals": true,
|
|
4
|
+
"jsonRecursiveSort": true,
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": ["Local State"],
|
|
8
|
+
"options": {
|
|
9
|
+
"parser": "json"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"files": [".config/k*rc", ".local/state/*rc"],
|
|
14
|
+
"options": {
|
|
15
|
+
"parser": "ini"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"printWidth": 100,
|
|
20
|
+
"reorderKeys": true,
|
|
21
|
+
"singleQuote": true
|
|
22
|
+
}
|
baldwin/utils.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from importlib import resources
|
|
3
|
+
from itertools import chain
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from shlex import quote
|
|
6
|
+
from shutil import which
|
|
7
|
+
import logging
|
|
8
|
+
import subprocess as sp
|
|
9
|
+
|
|
10
|
+
from git import Repo
|
|
11
|
+
import platformdirs
|
|
12
|
+
|
|
13
|
+
__all__ = ('format_', 'get_git_path', 'get_repo')
|
|
14
|
+
|
|
15
|
+
log = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_git_path() -> Path:
|
|
19
|
+
"""
|
|
20
|
+
Get the bare Git directory (``GIT_DIR``).
|
|
21
|
+
|
|
22
|
+
This path is platform-specific. On Windows, the Roaming AppData directory will be used.
|
|
23
|
+
"""
|
|
24
|
+
return platformdirs.user_data_path('home-git', roaming=True)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_repo() -> Repo:
|
|
28
|
+
"""
|
|
29
|
+
Get a :py:class:`git.Repo` object.
|
|
30
|
+
|
|
31
|
+
Also disables GPG signing for the repository.
|
|
32
|
+
"""
|
|
33
|
+
repo = Repo(get_git_path(), expand_vars=False)
|
|
34
|
+
repo.git.execute(('git', 'config', 'commit.gpgsign', 'false'))
|
|
35
|
+
return repo
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def format_(filenames: Iterable[Path | str], log_level: str = 'error') -> None:
|
|
39
|
+
"""
|
|
40
|
+
Format untracked and modified files in the repository.
|
|
41
|
+
|
|
42
|
+
Does nothing if Prettier is not in ``PATH``.
|
|
43
|
+
|
|
44
|
+
The following plugins will be detected and enabled if found:
|
|
45
|
+
|
|
46
|
+
* @prettier/plugin-xml
|
|
47
|
+
* prettier-plugin-ini
|
|
48
|
+
* prettier-plugin-sort-json
|
|
49
|
+
* prettier-plugin-toml
|
|
50
|
+
"""
|
|
51
|
+
if not (filenames := list(filenames)):
|
|
52
|
+
return
|
|
53
|
+
with resources.path('baldwin.resources', 'prettier.config.json') as config_file:
|
|
54
|
+
if not (prettier := which('prettier')):
|
|
55
|
+
return
|
|
56
|
+
# Detect plugins
|
|
57
|
+
node_modules_path = (Path(prettier).resolve(strict=True).parent / '..' /
|
|
58
|
+
'..').resolve(strict=True)
|
|
59
|
+
cmd = ('prettier', '--config', str(config_file), '--write',
|
|
60
|
+
'--no-error-on-unmatched-pattern', '--ignore-unknown', '--log-level', log_level,
|
|
61
|
+
*chain(*(('--plugin', str(fp)) for module in (
|
|
62
|
+
'@prettier/plugin-xml/src/plugin.js', 'prettier-plugin-ini/src/plugin.js',
|
|
63
|
+
'prettier-plugin-sort-json/dist/index.js', 'prettier-plugin-toml/lib/index.cjs')
|
|
64
|
+
if (fp := (node_modules_path / module)).exists())), *(str(x)
|
|
65
|
+
for x in filenames))
|
|
66
|
+
log.debug('Running: %s', ' '.join(quote(x) for x in cmd))
|
|
67
|
+
sp.run(cmd, check=True)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: baldwin
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Simple tracking of your home directory with easy-to-read diffs.
|
|
5
|
+
Home-page: https://github.com/Tatsh/baldwin
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: command line,file management,git,version control
|
|
8
|
+
Author: Andrew Udvare
|
|
9
|
+
Author-email: audvare@gmail.com
|
|
10
|
+
Requires-Python: >=3.12,<4
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Dist: binaryornot (>=0.4.4,<0.5.0)
|
|
20
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
21
|
+
Requires-Dist: gitpython (>=3.1.43,<4.0.0)
|
|
22
|
+
Requires-Dist: platformdirs (>=4.3.6,<5.0.0)
|
|
23
|
+
Project-URL: Documentation, https://baldwin.readthedocs.org
|
|
24
|
+
Project-URL: Issues, https://github.com/Tatsh/baldwin/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/Tatsh/baldwin
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Simple home directory versioning
|
|
29
|
+
|
|
30
|
+
This is a conversion of my simple scripts to version my home directory with very specific excludes
|
|
31
|
+
and formatting every file upon commit so that readable diffs can be generated.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
pip install baldwin
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```plain
|
|
42
|
+
$ bw -h
|
|
43
|
+
Usage: bw [OPTIONS] COMMAND [ARGS]...
|
|
44
|
+
|
|
45
|
+
Manage a home directory with Git.
|
|
46
|
+
|
|
47
|
+
Options:
|
|
48
|
+
-d, --debug Enable debug logging.
|
|
49
|
+
-h, --help Show this message and exit.
|
|
50
|
+
|
|
51
|
+
Commands:
|
|
52
|
+
auto-commit
|
|
53
|
+
format
|
|
54
|
+
git
|
|
55
|
+
info
|
|
56
|
+
init
|
|
57
|
+
install-units
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
In addition to the `bw` command, `hgit` is a shortcut for `bw git`.
|
|
61
|
+
|
|
62
|
+
### Start a new repository
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
bw init
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Find out where the bare Git directory is by running `bw info`. This can be done even if `init` has
|
|
69
|
+
not been run.
|
|
70
|
+
|
|
71
|
+
### Automation
|
|
72
|
+
|
|
73
|
+
#### systemd
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
bw install-units
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This will install a timer that will automatically make a new commit every 6 hours. It does not push.
|
|
80
|
+
|
|
81
|
+
Keep in mind that systemd units require a full path to the executable, so you must keep the unit
|
|
82
|
+
up-to-date if you move where you install this package. Simply run `bw install-units` again.
|
|
83
|
+
|
|
84
|
+
Note that user systemd units only run while logged in.
|
|
85
|
+
|
|
86
|
+
To disable and remove the units, use the following commands:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
systemctl disable --now home-vcs.timer
|
|
90
|
+
rm ~/.config/systemd/user/home-vcs.*
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Pushing
|
|
94
|
+
|
|
95
|
+
To push, use either of the following:
|
|
96
|
+
|
|
97
|
+
- `bw git push`
|
|
98
|
+
- `hgit push`
|
|
99
|
+
|
|
100
|
+
The above also demonstrates that `bw git`/`hgit` are just frontends to `git` with the correct
|
|
101
|
+
environment applied.
|
|
102
|
+
|
|
103
|
+
## Formatting
|
|
104
|
+
|
|
105
|
+
If Prettier is installed, it will be used to format files. The configuration used comes with this
|
|
106
|
+
package. Having consistent formatting allows for nice diffs to be generated.
|
|
107
|
+
|
|
108
|
+
If you have initialised a repository without having `prettier` or `jq` in `PATH`, you need to run the
|
|
109
|
+
following commands to enable readable diffs:
|
|
110
|
+
|
|
111
|
+
```shell
|
|
112
|
+
hgit config diff.json.textconv 'jq -MS .'
|
|
113
|
+
hgit config diff.json.cachetextconv true
|
|
114
|
+
hgit config diff.yaml.textconv 'prettier --no-editorconfig --parser yaml'
|
|
115
|
+
hgit config diff.yaml.cachetextconv true
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
If you have the XML plugin installed:
|
|
119
|
+
|
|
120
|
+
```shell
|
|
121
|
+
hgit config diff.xml.textconv 'prettier --no-editorconfig --parser xml --xml-whitespace-sensitivity ignore'
|
|
122
|
+
hgit config diff.xml.cachetextconv true
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Binary files
|
|
126
|
+
|
|
127
|
+
Any file that is untracked and detected to be binary will not be added. Use `hgit add` to add a
|
|
128
|
+
binary file manually.
|
|
129
|
+
|
|
130
|
+
## Other details
|
|
131
|
+
|
|
132
|
+
Default `.gitignore` and `.gitattributes` files are installed on initialisation. They are never
|
|
133
|
+
modified by this tool. Please customise as necessary.
|
|
134
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
baldwin/__init__.py,sha256=paQL6NkltnuTQieOUMgQnzOOWTuxSXo5ztGywTkWvA8,62
|
|
2
|
+
baldwin/main.py,sha256=AeDKsoVMVXzcyoCBx0vSVRsDZbcmwHY-iLCGZaeGMIo,5619
|
|
3
|
+
baldwin/resources/default_gitattributes.txt,sha256=uGoWTSVgPmdGB2EUIROkTz3FikGpNGhdS95SuuvoCRo,984
|
|
4
|
+
baldwin/resources/default_gitignore.txt,sha256=oyxukNyK6F778C2jc7oIwosP7ou1WTdbuWwkpgGZtJA,3022
|
|
5
|
+
baldwin/resources/prettier.config.json,sha256=-Hher3B02YflULYn0IYOG_a-rDxpaaaQ0QXD30-5IgQ,387
|
|
6
|
+
baldwin/utils.py,sha256=gOtDvylunSQoZ8QN8RvEeafPCw8Xn42vOflTMxciHtg,2330
|
|
7
|
+
baldwin-0.0.1.dist-info/METADATA,sha256=bZyV63vjrEvAgEctu6edftMqO5fsUFNCCG8Nuan5TJg,3659
|
|
8
|
+
baldwin-0.0.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
9
|
+
baldwin-0.0.1.dist-info/entry_points.txt,sha256=Whfij6CPUG0wuXRYWf3VGkluV1jV32ysrGFdlWjFy9o,70
|
|
10
|
+
baldwin-0.0.1.dist-info/RECORD,,
|