Skip to content

Commit d015703

Browse files
committed
fix: readme updater formula repo path
1 parent ed8bad8 commit d015703

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v2.1.2 (2025-06-23)
4+
5+
- Fixes Readme Updater path to use new tmp path for formula repo
6+
37
## v2.1.1 (2025-06-14)
48

59
- Corrects Python references in Dockerfile

homebrew_releaser/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.1.1'
1+
__version__ = '2.1.2'

homebrew_releaser/readme_updater.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ def does_readme_exist(homebrew_tap: str) -> Optional[str]:
188188
"""
189189
readme_to_open = None
190190
readme_filename = 'readme.md'
191-
files = os.listdir(homebrew_tap)
191+
tap_dir = Utils.get_working_dir(homebrew_tap)
192+
files = os.listdir(tap_dir)
192193

193194
for filename in files:
194195
if filename.lower() == readme_filename:
195-
readme_to_open = Utils.get_working_dir(os.path.join(homebrew_tap, filename))
196+
readme_to_open = os.path.join(tap_dir, filename)
196197
break
197198

198199
return readme_to_open

test/unit/test_readme_updater.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_format_formula_data():
7575
Here, we reuse our 'recorded' formulas from the test suite as the dummy formulas that may have
7676
been found in a user's git repo.
7777
"""
78-
formulas = ReadmeUpdater.format_formula_data('./test')
78+
formulas = ReadmeUpdater.format_formula_data('test')
7979

8080
assert len(formulas) == 16
8181
assert formulas[1] == {
@@ -92,7 +92,7 @@ def test_format_formula_data_error_reading_formula():
9292
with patch('builtins.open', mock_open()) as mock_opening:
9393
mock_opening.side_effect = OSError
9494
with pytest.raises(SystemExit) as error:
95-
ReadmeUpdater.format_formula_data('./test')
95+
ReadmeUpdater.format_formula_data('test')
9696

9797
assert str(error.value) == 'There was a problem opening or reading the formula data: '
9898

@@ -128,6 +128,7 @@ def test_retrieve_old_table_not_found():
128128
assert old_table_found is False
129129

130130

131+
@patch('homebrew_releaser.utils.WORKING_DIR', '')
131132
@pytest.mark.parametrize(
132133
'table_content',
133134
[
@@ -156,16 +157,17 @@ def test_retrieve_old_table(table_content):
156157
@patch('logging.Logger.error')
157158
def test_retrieve_old_table_no_readme(mock_logger):
158159
"""Tests that we retrieve only the old table data when start and end tags exist."""
159-
old_table, old_table_found = ReadmeUpdater.retrieve_old_table('./test')
160+
old_table, old_table_found = ReadmeUpdater.retrieve_old_table('test')
160161

161162
mock_logger.assert_called_once_with('Could not find a valid README in this project to update.')
162163
assert old_table == ''
163164
assert old_table_found is False
164165

165166

167+
@patch('homebrew_releaser.utils.WORKING_DIR', '')
166168
def test_read_current_readme_does_not_exist():
167169
"""Tests that the file contents of a README that doesn't exist is empty."""
168-
readme = ReadmeUpdater.read_current_readme('./test')
170+
readme = ReadmeUpdater.read_current_readme('test')
169171

170172
assert readme == ""
171173

@@ -178,6 +180,7 @@ def test_read_current_readme():
178180
assert '# Homebrew Releaser' in readme
179181

180182

183+
@patch('homebrew_releaser.utils.WORKING_DIR', '')
181184
def test_replace_table_contents():
182185
"""Test that we add the new README changes to git."""
183186
with patch('builtins.open', mock_open()):
@@ -189,6 +192,7 @@ def test_replace_table_contents():
189192
)
190193

191194

195+
@patch('homebrew_releaser.utils.WORKING_DIR', '')
192196
@patch('logging.Logger.debug')
193197
@patch('homebrew_releaser.git.Git.add')
194198
def test_replace_table_contents_no_readme(mock_git_add, mock_logger):
@@ -197,7 +201,7 @@ def test_replace_table_contents_no_readme(mock_git_add, mock_logger):
197201
file_content='mock file contents',
198202
old_table='old table contents',
199203
new_table='new table contents',
200-
homebrew_tap='./test',
204+
homebrew_tap='test',
201205
)
202206

203207
mock_logger.assert_not_called()

0 commit comments

Comments
 (0)