Skip to content

Commit d33e684

Browse files
committed
fix: use '=' as the delimiter for cask arguments
refactor: replace git config init.defaultBranch with git branch --show-current docs: add instructions for setting pseudo git user refactor: pass opt dictionary instead of brewfile string to BrewFile constructor test: add --no-repo option to prevent git init during format options tests
1 parent 1e017ed commit d33e684

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

bin/brew-file

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ class BrewInfo:
914914
self.cask_args_input[k] = v
915915
else:
916916
for arg in excmd.split():
917-
k = arg.split(':')[0]
917+
k = arg.split('=')[0]
918918
v = arg.split('=')[1] if '=' in arg else ''
919919
self.cask_args_input[k] = v
920920
else:
@@ -1659,10 +1659,14 @@ class BrewFile:
16591659
['git', 'commit', '-m', '"Prepared by ' + __prog__ + '"'],
16601660
cwd=dirname,
16611661
)
1662-
_, lines = self.helper.proc('git config init.defaultBranch')
1663-
default_branch = lines[0]
1662+
_, lines = self.helper.proc(
1663+
'git branch --show-current',
1664+
cwd=dirname,
1665+
exit_on_err=False,
1666+
)
1667+
branch = lines[0]
16641668
self.helper.proc(
1665-
f'git push -u origin {default_branch}',
1669+
f'git push -u origin {branch}',
16661670
cwd=dirname,
16671671
)
16681672

docs/development.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ Prepare Homebrew::
131131

132132
==> Casks
133133

134+
Set pseudo git user::
135+
136+
lume@lumes-Virtual-Machine ~ % git config --global user.name "lume"
137+
lume@lumes-Virtual-Machine ~ % git config --global user.email "lume@localhost"
138+
134139
Install pytest, filelock by pip::
135140

136141
lume@lumes-Virtual-Machine ~ % pip3 install pytest filelock

src/brew_file/brew_file.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,14 @@ def init_repo(self) -> None:
492492
['git', 'commit', '-m', '"Prepared by ' + __prog__ + '"'],
493493
cwd=dirname,
494494
)
495-
_, lines = self.helper.proc('git config init.defaultBranch')
496-
default_branch = lines[0]
495+
_, lines = self.helper.proc(
496+
'git branch --show-current',
497+
cwd=dirname,
498+
exit_on_err=False,
499+
)
500+
branch = lines[0]
497501
self.helper.proc(
498-
f'git push -u origin {default_branch}',
502+
f'git push -u origin {branch}',
499503
cwd=dirname,
500504
)
501505

src/brew_file/brew_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def read(self) -> None:
361361
self.cask_args_input[k] = v
362362
else:
363363
for arg in excmd.split():
364-
k = arg.split(':')[0]
364+
k = arg.split('=')[0]
365365
v = arg.split('=')[1] if '=' in arg else ''
366366
self.cask_args_input[k] = v
367367
else:

tests/test_serial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def test_clean_non_request(
563563
brewfile: str,
564564
helper: BrewHelper,
565565
) -> None:
566-
bf = BrewFile(brewfile)
566+
bf = BrewFile(opt={'input': brewfile})
567567
helper.proc('brew install brotli')
568568
bf.clean_non_request()
569569
_, lines = helper.proc('brew ls')
@@ -751,7 +751,7 @@ def test_format_options(
751751
helper.proc('brew install git')
752752
formats = ['file', 'bundle', 'cmd']
753753
for fmt in formats:
754-
helper.proc(f'"{cmd}" init -f "{brewfile}" -y -F {fmt}')
754+
helper.proc(f'"{cmd}" init -f "{brewfile}" -y --no-repo -F {fmt}')
755755
assert Path(brewfile).exists()
756756
with Path(brewfile).open() as f:
757757
content = f.read()

0 commit comments

Comments
 (0)