Skip to content

Commit

Permalink
Fix Replace not working in packs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilus committed Nov 1, 2021
1 parent 3596cce commit 3cab0dd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Ensure non-zero exit code from a command in Oya tasks, including sub-commands,
propagates to the shell invoking `oya run`, even without `set -e`.

- Fix `Replace` directive having no effect when used in imported packs.

### Added

- REPL, helping build scripts interactively with access to values in .oya files
Expand Down
38 changes: 38 additions & 0 deletions features/development.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,41 @@ Scenario: With local require oya doesn't attempt to lookup requirements remotely
"""
When I run "oya run foo.version"
Then the command succeeds

Scenario: Replace directive works in packs
Given file ./Oyafile containing
"""
Project: project
Require:
github.com/tooploox/does-not-exist: v1.0.0
Replace:
github.com/tooploox/does-not-exist: /tmp/pack1
Import:
foo: github.com/tooploox/does-not-exist
"""
And file /tmp/pack1/Oyafile containing
"""
Project: pack1
Require:
github.com/tooploox/does-not-exist2: v1.0.0
Replace:
github.com/tooploox/does-not-exist2: /tmp/pack2
Import:
foo: github.com/tooploox/does-not-exist2
version: echo 1.0.0
"""
And file /tmp/pack2/Oyafile containing
"""
Project: pack2
version: echo 1.0.0
"""
When I run "oya run foo.version"
Then the command succeeds
10 changes: 8 additions & 2 deletions pkg/deptree/internal/reqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,22 @@ func (r *Reqs) remoteReqs(p pack.Pack) ([]pack.Pack, error) {
return l.Reqs(p.Version())
}

// TODO(bilus): The same logic is in resolvePackReferences in packs.go
func toPacks(references []oyafile.PackReference) ([]pack.Pack, error) {
packs := make([]pack.Pack, len(references))
for i, reference := range references {
repo, err := repo.Open(reference.ImportPath)
l, err := repo.Open(reference.ImportPath)
if err != nil {
return nil, err
}
if packs[i], err = repo.Version(reference.Version); err != nil {
pack, err := l.Version(reference.Version)
if err != nil {
return nil, err
}
if len(reference.ReplacementPath) > 0 {
pack = pack.LocalReplacement(reference.ReplacementPath)
}
packs[i] = pack
}
return packs, nil
}

0 comments on commit 3cab0dd

Please sign in to comment.