Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use source-subdir in go-use plugin #980

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion craft_parts/plugins/go_use_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ def get_build_commands(self) -> list[str]:
)

return [
f"go work use {self._part_info.part_src_dir}",
f"go work use {self._part_info.part_src_subdir}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain to me why these are the source dir/subdir and not the build dir/subdir? It's not a blocker for this, it's just that the latter makes more sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know actually
@sergiusens ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the before times, src was not copied of to build

]
12 changes: 11 additions & 1 deletion docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
Changelog
*********

2.2.2 (2025-MM-DD)
X.Y.Z (2025-MM-DD)
------------------

Bug fixes:

- Make sure the :ref:`uv plugin<craft_parts_uv_plugin>` is re-entrant on
source changes.
- Correctly handle ``source-subdir`` values on the ``go-use`` plugin.

Documentation:

- Correct the Maven plugin docstring to refer to Maven from Go.


2.2.2 (2025-MM-DD)
------------------

Documentation:

- Add a cross-reference target for Poetry external links.


2.2.1 (2024-12-19)
------------------

Expand Down
22 changes: 20 additions & 2 deletions tests/unit/plugins/test_go_use_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_get_build_commands(mocker, part_info, go_workspace):
)

assert plugin.get_build_commands() == [
f"go work use {plugin._part_info.part_src_dir}",
f"go work use {plugin._part_info.part_src_subdir}",
]
run_mock.assert_called_once_with(
["go", "work", "init"], capture_output=True, check=True, cwd=go_workspace.parent
Expand All @@ -182,6 +182,24 @@ def test_get_build_commands_workspace_in_use(mocker, part_info):
run_mock = mocker.patch("subprocess.run")

assert plugin.get_build_commands() == [
f"go work use {plugin._part_info.part_src_dir}",
f"go work use {plugin._part_info.part_src_subdir}",
]
run_mock.assert_not_called()


@pytest.mark.usefixtures("go_workspace")
def test_get_build_commands_subdir(mocker, new_dir):
part_spec = {"source": ".", "source-subdir": "my/subdir"}
part_info = PartInfo(
project_info=ProjectInfo(application_name="test", cache_dir=new_dir),
part=Part("my-part", part_spec),
)
properties = GoUsePlugin.properties_class.unmarshal(part_spec)
plugin = GoUsePlugin(properties=properties, part_info=part_info)

run_mock = mocker.patch("subprocess.run")

assert plugin.get_build_commands() == [
f"go work use {plugin._part_info.part_src_subdir}",
]
run_mock.assert_not_called()
Loading