Skip to contentSkip to conversation

oe-layertool-setup: general clean up and bugfix

PATCH In review [email protected] 2 participants 7 messages Feb 5 – Feb 6

lore
Share & tools
lore
#2 lore raw

PATCH 2/5 oe-layertool-setup: trim trailing whitespace

In reply to [email protected]

From: Randolph Sapp <[email protected]>

Trim the existing trailing whitespace to align with editorconfig.

---
 oe-layertool-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
oe-layertool-setup.sh +3 -3
index eb412ff..cd6d04e 100755
@@ -136,7 +136,7 @@ check_input() {
     if [ ! -f "$inputfile" ]
     then
         printf '%s\n' "ERROR: the file \"$inputfile\" given for inputfile does not exist"
-        usage 
+        usage
     fi
 
     # If directories do not exist then create them
@@ -348,7 +348,7 @@ configure_repo() {
         printf '%s\n' "Skipping configuring duplicate repository"
         return 1
     fi
-  
+
     if [ -z "$uri" ]
     then
         get_repo_uri
@@ -431,7 +431,7 @@ The $name repository has the following branches available:
 
 $branches
 
-What branch would you like to checkout for the $name repository? 
+What branch would you like to checkout for the $name repository?
 EOM
         read -r input
 
Signature · 1 line
2.52.0
#0 lore raw

cover oe-layertool-setup: general clean up and bugfix

From: Randolph Sapp <[email protected]>

Fix a previously reported bug with checking out local branches that already exist. Prevent infinite input loops when no config templates are provided. Add an editorconfig to prevent erroneous whitespace changes. Use git to trim ref parts instead of external sed logic.

Sorry this took so long Jon. Completely forgot about it.

Randolph Sapp (5):
editorconfig: add a shared editor configuration
oe-layertool-setup: trim trailing whitespace
oe-layertool-setup: fix config template parsing
oe-layertool-setup: fix bug with branch checkout
oe-layertool-setup: use git to trim ref parts

 .editorconfig         | 15 +++++++++++++++
 oe-layertool-setup.sh | 30 ++++++++++++++++++------------
 2 files changed, 33 insertions(+), 12 deletions(-)
 create mode 100644 .editorconfig

--
2.52.0

#6 lore raw

PATCH 5/5 oe-layertool-setup: use git to trim ref parts

From: Randolph Sapp <[email protected]>

Use git formatting to strip ref parts more consistently. Tighten grep patterns to make sure we don't get any partial matches.

---
 oe-layertool-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
oe-layertool-setup.sh +3 -3
index db870af..dff2565 100755
@@ -416,10 +416,10 @@ get_repo_branch() {
 
         # Get a unique list of branches for the user to chose from
         # Also delete the origin/HEAD line that the -r option returns
-        t_branches=$(git branch -r | sed '/origin\/HEAD/d')
+        t_branches=$(git branch -r --format='%(refname:strip=3)' | grep -v '^HEAD$')
         for b in $t_branches
         do
-            branches="${branches}$(printf '%s\n' "$b" | sed 's:.*origin/::g')\n"
+            branches="${branches}$(printf '%s\n' "$b")\n"
         done
         branches=$(printf '%s\n' "$branches" | sort | uniq)
 
@@ -460,7 +460,7 @@ checkout_branch() {
     # Check if a local branch already exists to track the remote branch.
     # If not then create a tracking branch and checkout the branch
     # else just checkout the existing branch
-    if git branch | grep -q "$branch"
+    if git branch --format='%(refname:short)' | grep -q "^$branch\$"
     then
         git checkout "$branch"
     else
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/5 editorconfig: add a shared editor configuration

In reply to [email protected]

From: Randolph Sapp <[email protected]>

Add an editorconfig to keep track of the various file types and their current whitespace patterns, even some of them may break traditional conventions.

---
 .editorconfig | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 .editorconfig
.editorconfig new file +15 -0
new file mode 100644
index 0000000..30740e7
@@ -0,0 +1,15 @@
+# Shared editor configuration <https://editorconfig.org>
+
+root = true
+
+[*]
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{sh,pl,xml}]
+indent_size = 4
+indent_style = space
+
+[*.{yml,json,xslt}]
+indent_size = 2
+indent_style = space
Signature · 1 line
2.52.0
#4 lore raw

PATCH 3/5 oe-layertool-setup: fix config template parsing

In reply to [email protected]

From: Randolph Sapp <[email protected]>

It may be possible that someone submits a config without any templates. In this case we should not enter an infinite loop, nor should we try to copy empty strings.

---
 oe-layertool-setup.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
oe-layertool-setup.sh +10 -4
index cd6d04e..979390f 100755
@@ -658,7 +658,7 @@ get_oecorelayerconf() {
 
     done="n"
 
-    while [ "$done" != "y" ]
+    while [ "$done" != "y" ] && [ -n "$confs" ]
     do
 
 cat << EOM
@@ -713,7 +713,7 @@ get_oecorelocalconf() {
 
     done="n"
 
-    while [ "$done" != "y" ]
+    while [ "$done" != "y" ] && [ -n "$confs" ]
     do
 
 cat << EOM
@@ -765,7 +765,10 @@ NOTE: Any additional entries to this file will be lost if the $0
 
 EOM
     # First copy the template file
-    cp -f "$OECORELAYERCONFPATH" "$confdir/bblayers.conf"
+    if [ -n "$OECORELAYERCONFPATH" ]
+    then
+        cp -f "$OECORELAYERCONFPATH" "$confdir/bblayers.conf"
+    fi
 
     # Now add the layers we have configured to the BBLAYERS variable
 cat >> "$confdir/bblayers.conf" << EOM
@@ -806,7 +809,10 @@ EOM
     fi
 
     # First copy the template file
-    cp -f "$OECORELOCALCONFPATH" "$confdir/local.conf"
+    if [ -n "$OECORELOCALCONFPATH" ]
+    then
+        cp -f "$OECORELOCALCONFPATH" "$confdir/local.conf"
+    fi
 
     # If command line option was not set use the old dldir
     if [ -z "$dldir" ]
Signature · 1 line
2.52.0
#5 lore raw

PATCH 4/5 oe-layertool-setup: fix bug with branch checkout

In reply to [email protected]

From: Randolph Sapp <[email protected]>

Switch the if/else branches to correctly deal with a local branch that already matches our expected branch name.

---
 oe-layertool-setup.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
oe-layertool-setup.sh +2 -2
index 979390f..db870af 100755
@@ -462,9 +462,9 @@ checkout_branch() {
     # else just checkout the existing branch
     if git branch | grep -q "$branch"
     then
-        git checkout "origin/$branch" -b "$branch" --track
-    else
         git checkout "$branch"
+    else
+        git checkout "origin/$branch" -b "$branch" --track
     fi
 
     # Now that we are on the proper branch pull the remote branch changes if
Signature · 1 line
2.52.0
#3 lore raw

Re: [meta-arago][oe-layersetup][PATCH 2/5] oe-layertool-setup: trim trailing whitespace

In reply to [email protected]
Quoted 3 lines · Randolph Sapp via lists.yoctoproject.org

From: Randolph Sapp <[email protected]>

Trim the existing trailing whitespace to align with editorconfig.

Unfrotunately, this will not come through as an inline patch via the mailing list.

Ryan will have to apply the original patch or make the same changes on his side.

Quoted 38 lines
---
 oe-layertool-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
oe-layertool-setup.sh +3 -3
index eb412ff..cd6d04e 100755
@@ -136,7 +136,7 @@ check_input() {
     if [ ! -f "$inputfile" ]
     then
         printf '%s\n' "ERROR: the file \"$inputfile\" given for inputfile does not exist"
-        usage 
+        usage
     fi
 
     # If directories do not exist then create them
@@ -348,7 +348,7 @@ configure_repo() {
         printf '%s\n' "Skipping configuring duplicate repository"
         return 1
     fi
-  
+
     if [ -z "$uri" ]
     then
         get_repo_uri
@@ -431,7 +431,7 @@ The $name repository has the following branches available:
 
 $branches
 
-What branch would you like to checkout for the $name repository? 
+What branch would you like to checkout for the $name repository?
 EOM
         read -r input
 
Signature · 1 line
2.52.0