You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/30 11:36:54 UTC
[mynewt-newt] 02/02: Fix resolving project relative path
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 4f847e5873775a10832550c27b919bc417f0d2cc
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Mar 30 12:03:48 2022 +0200
Fix resolving project relative path
Path for .newtrc is resolved before project is created.
---
newt/newtutil/newtutil.go | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index f425fda..856ef4c 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -22,6 +22,7 @@ package newtutil
import (
"fmt"
"io/ioutil"
+ "path/filepath"
"strconv"
"strings"
@@ -178,12 +179,17 @@ func MakeTempRepoDir() (string, error) {
}
func ProjRelPath(path string) string {
- if strings.HasPrefix(path, "/") {
- return path
+ if filepath.IsAbs(path) {
+ proj := interfaces.GetProject()
+ if proj != nil {
+ relPath, err := filepath.Rel(proj.Path(), path)
+ if err == nil {
+ path = relPath
+ }
+ }
}
- proj := interfaces.GetProject()
- return strings.TrimPrefix(path, proj.Path()+"/")
+ return path
}
func PrintNewtVersion() {