@@ -9,11 +9,11 @@ import (
9
9
"io"
10
10
"net/http"
11
11
"os"
12
+ "os/exec"
12
13
"path/filepath"
13
14
"strings"
14
15
15
16
"github.com/codeclysm/extract/v4"
16
- "github.com/go-git/go-git/v5"
17
17
cp "github.com/otiai10/copy"
18
18
)
19
19
@@ -58,7 +58,7 @@ func main() {
58
58
}
59
59
defer os .RemoveAll (tmpDir ) // Clean up
60
60
61
- // Download the zip file from http://downloads.arduino.cc/cores/zephyr/zephyr-core-llext -{git_tag}.zip
61
+ // Download the zip file from http://downloads.arduino.cc/cores/zephyr/ArduinoCore-zephyr -{git_tag}.zip
62
62
// and save it to zipFilePath
63
63
// Replace {git_tag} with the actual git tag
64
64
@@ -68,45 +68,46 @@ func main() {
68
68
if len (os .Args ) > 2 {
69
69
forceHash = os .Args [2 ]
70
70
}
71
- r , err := git .PlainOpen (gitCorePath )
71
+
72
+ cmd := exec .Command ("git" , "ls-files" , "--exclude-standard" , "-dmo" , "." )
73
+ stdout , err := cmd .Output ()
72
74
if err != nil {
73
- fmt .Println ("Error opening git repository :" , err )
75
+ fmt .Println ("Error executing command :" , err )
74
76
return
75
77
}
76
- ref , err := r .Head ()
77
- if err != nil {
78
- fmt .Println ("Error getting git reference:" , err )
79
- return
78
+
79
+ var lines []string
80
+ var failures []string
81
+ lines = strings .Split (string (stdout ), "\n " )
82
+ for _ , path := range lines {
83
+ if strings .HasPrefix (path , "firmwares/" ) || strings .HasPrefix (path , "variants/" ) {
84
+ failures = append (failures , path )
85
+ }
80
86
}
81
- w , err := r .Worktree ()
82
- if err != nil {
83
- fmt .Println ("Error getting git worktree:" , err )
87
+
88
+ if len (failures ) > 0 {
89
+ fmt .Println ("The git repository contains uncommitted changes:" )
90
+ for _ , path := range failures {
91
+ fmt .Println ("- " , path )
92
+ }
93
+ fmt .Println ("Please stash them before running this script." )
84
94
return
85
95
}
86
- // Check if the repo contains modifications in either variants or firmwares folders
87
- status , err := w .StatusWithOptions (git.StatusOptions {Strategy : git .Preload })
96
+
97
+ cmd = exec .Command ("git" , "describe" , "--always" , "--abbrev=7" )
98
+ stdout , err = cmd .Output ()
88
99
if err != nil {
89
- fmt .Println ("Error getting git status :" , err )
100
+ fmt .Println ("Error executing command :" , err )
90
101
return
91
102
}
92
- if ! status .IsClean () {
93
- // Check if there are untracked/modified files in the firmwares or variants folders
94
- for path , s := range status {
95
- if strings .HasPrefix (path , "firmwares/" ) || strings .HasPrefix (path , "variants/" ) {
96
- fmt .Println ("The git repository contains uncommitted changes in" , path )
97
- if s .Worktree != git .Untracked {
98
- fmt .Println ("Please stash them before running this script." )
99
- }
100
- return
101
- }
102
- }
103
- }
104
- fmt .Println ("Git tag:" , ref .Hash ())
105
- // Replace {git_tag} with the actual git tag in the URL
106
- hash := ref .Hash ().String ()[0 :7 ]
103
+
104
+ hash := strings .TrimSpace (string (stdout ))
105
+ fmt .Println ("Git SHA:" , hash )
107
106
if forceHash != "" {
108
107
hash = forceHash
109
108
}
109
+
110
+ // Compose download URL from git hash
110
111
filename := fmt .Sprintf ("ArduinoCore-zephyr-%s.tar.bz2" , hash )
111
112
url := fmt .Sprintf ("http://downloads.arduino.cc/cores/zephyr/%s" , filename )
112
113
fmt .Println ("Download URL:" , url )
0 commit comments