This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 89479dfced66de1b2b1561c77666faf9de6ab462
Author: Szymon Janc <[email protected]>
AuthorDate: Fri Oct 16 17:23:02 2026 +0200

    newt/deprepo: Resolve dependencies of commit pinned repos
    
    Dependencies of a repo pinned to a commit (e.g. "<sha>-commit") were
    never resolved. The dependency graph has nodes for versions only, so
    looking up the pinned version, which includes the commit, found
    nothing. Dependencies of the pinned repo stayed at whatever version
    was checked out when they were cloned, i.e. their main branch.
    
    Look up the graph without the commit, so a pinned repo depends on what
    its version number does. This matches Repo.DepsForVersion and how
    dependencies of pinned repos are loaded since 461da719d.
    
    Dependencies of pinned repos now take part in conflict detection, so
    conflict02 reports one more conflict: repo 03 pinned to a commit
    requires repo 02 0.0.0, while project.yml requires 1.0.0.
    
    The commit-deps project pins repo 06 to its master commit, which
    depends on repo 05 1.0.0 (not repo 05 master, so that a missing
    upgrade is not hidden by a fresh clone) and must not pull repo 04.
    The latter also covers 461da719d.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/deprepo/deprepo.go                            |  7 +++++-
 newt/testdata/upgrade/fail/conflict02/expected.txt |  4 ++++
 newt/testdata/upgrade/fail/conflict02/project.yml  |  3 ++-
 .../upgrade/success/commit-deps/expected.txt       |  2 ++
 .../upgrade/success/commit-deps/project.yml        | 26 ++++++++++++++++++++++
 5 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/newt/deprepo/deprepo.go b/newt/deprepo/deprepo.go
index 5d7faa5a..6bbc7ac8 100644
--- a/newt/deprepo/deprepo.go
+++ b/newt/deprepo/deprepo.go
@@ -288,7 +288,12 @@ func ResolveRepoDeps(dg DepGraph) (VersionMap, []Conflict) 
{
        // Adds one entry to the working set (ws) for each of the given repo's
        // dependencies.
        visit := func(rvp RVPair) {
-               nodes := dg[rvp]
+               // The graph has no nodes for commits.  A repo pinned to a 
commit
+               // depends on what its version number does, as during install 
(see
+               // Repo.DepsForVersion).
+               key := rvp
+               key.Ver.Commit = ""
+               nodes := dg[key]
                for _, node := range nodes {
                        addWsNode(rvp, node)
                }
diff --git a/newt/testdata/upgrade/fail/conflict02/expected.txt 
b/newt/testdata/upgrade/fail/conflict02/expected.txt
index 24172f5c..b36e69ab 100644
--- a/newt/testdata/upgrade/fail/conflict02/expected.txt
+++ b/newt/testdata/upgrade/fail/conflict02/expected.txt
@@ -1,4 +1,8 @@
 Error: Repository conflicts:
+    Installation of repo "mynewt-dummy-repo-02" is blocked:
+                       project.yml requires mynewt-dummy-repo-02/1.0.0
+    mynewt-dummy-repo-03/ff71469039b3d63cb0925e866c6a6dfb7d41a055 requires 
mynewt-dummy-repo-02/0.0.0
+
     Installation of repo "mynewt-dummy-repo-04" is blocked:
                        project.yml requires mynewt-dummy-repo-04/1.0.2
         mynewt-dummy-repo-01/1.0.0 requires mynewt-dummy-repo-04/1.0.0
diff --git a/newt/testdata/upgrade/fail/conflict02/project.yml 
b/newt/testdata/upgrade/fail/conflict02/project.yml
index f085f169..88df375b 100644
--- a/newt/testdata/upgrade/fail/conflict02/project.yml
+++ b/newt/testdata/upgrade/fail/conflict02/project.yml
@@ -29,7 +29,8 @@ repository.mynewt-dummy-repo-05:
 
 ### Project overrides of repo-01 dependencies:
 
-# This override is compatible with the repo-01 dependency.
+# This override is compatible with the repo-01 dependency, but conflicts
+# with the dependency of the pinned repo-03 (that of its version, 0.0.0).
 repository.mynewt-dummy-repo-02:
    type: git
    vers: 1.0.0
diff --git a/newt/testdata/upgrade/success/commit-deps/expected.txt 
b/newt/testdata/upgrade/success/commit-deps/expected.txt
new file mode 100644
index 00000000..5eb1da22
--- /dev/null
+++ b/newt/testdata/upgrade/success/commit-deps/expected.txt
@@ -0,0 +1,2 @@
+    * mynewt-dummy-repo-05: 492b7645830e8f103c2de840d273c55112e8f960, 1.0.0
+    * mynewt-dummy-repo-06: 87674f20557cf2bc2597b3b1284a3a5f0c92338c, 2.0.0
diff --git a/newt/testdata/upgrade/success/commit-deps/project.yml 
b/newt/testdata/upgrade/success/commit-deps/project.yml
new file mode 100644
index 00000000..a95becf5
--- /dev/null
+++ b/newt/testdata/upgrade/success/commit-deps/project.yml
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+### Dependencies of a commit pinned repo-06 are those of its version
+### number (0.0.0, i.e. master), so repo-04 must not be installed.
+
+repository.mynewt-dummy-repo-06:
+   type: git
+   vers: 87674f20557cf2bc2597b3b1284a3a5f0c92338c-commit
+   url: 'https://dummy.invalid/mynewt-dummy-repo-06.git'

Reply via email to