Unnecessary priming of dependency when priming a part
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Bug Description
If a part depends on another, using `after`, and this part is primed, the dependency will be primed too.
`dependency_prerequisite_step` (see https://github.com/canonical/craft-parts/blob/main/craft_parts/steps.py#L85) should probably be fixed to be:
```python
def dependency_prerequisite_step(step: Step) -> Step | None:
"""Obtain the step a given step may depend on.
:returns: The prerequisite step.
"""
# With V2 plugins we don't need to repull if dependency is restaged
if step <= Step.OVERLAY:
return None
return Step.STAGE
```
### To Reproduce
`python3 -mcraft_parts -v --dry-run prime bar`
### part yaml
```shell
parts:
bar:
after: [foo]
plugin: nil
foo:
plugin: nil
```
### Relevant log output
```shell
Pull bar
Pull foo (required to overlay 'bar')
Overlay foo (required to overlay 'bar')
Overlay bar
Build foo (required to build 'bar')
Stage foo (required to build 'bar')
Build bar
Stage bar
Prime foo (required to prime 'bar')
Prime bar
```
Evaluation history
No evaluation history available.