Skip to content

Commit a91e61c

Browse files
committed
dev
1 parent 46c7beb commit a91e61c

File tree

2 files changed

+117
-12
lines changed

2 files changed

+117
-12
lines changed

stream/UpdateModsByWorkSpace.go

Lines changed: 106 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ var skips = []string{
2828
// git ls-remote https://github.com/gioui/gio refs/heads/main
2929
// 但是要传递本地的仓库目录,太麻烦了
3030
func GetLastCommitHash(repositoryName string) string {
31+
//理论上获取到hash再使用模块代理,这样才刷新的快?
32+
//或者使用action得到hash先?
33+
3134
mylog.Check(os.Setenv("GOPROXY", "direct")) // 如果模块代理导致获取到的不是最新的提交哈希那么需要禁用模块代理,最可靠的方式是 GetLastCommitHashLocal
32-
//defer mylog.Check(os.Setenv("GOPROXY", "https://goproxy.cn,direct"))
33-
defer RunCommand("go env -w GOPROXY=https://goproxy.cn,direct")
35+
defer mylog.Check(os.Setenv("GOPROXY", "https://goproxy.cn,direct"))
36+
37+
//defer RunCommand("go env -w GOPROXY=https://goproxy.cn,direct")
3438
s := RunCommand("git ls-remote " + repositoryName + " refs/heads/master").Output.String()
3539
for hash := range strings.FieldsSeq(s) {
3640
return hash
@@ -52,16 +56,107 @@ func GetLastCommitHash(repositoryName string) string {
5256
*/
5357
}
5458

55-
type Mod struct {
56-
modName string //gioui.org
57-
repositoryName string //https://github.com/gioui/gio
58-
repositoryDir string //GetLastCommitHashLocal
59-
hash string //GetLastCommitHash or GetLastCommitHashLocal
60-
updateCommand string //go get -x gioui.org@hash
59+
type ModInfo struct {
60+
ModName string //gioui.org
61+
RepositoryUrl string //https://github.com/gioui/gio
62+
repositoryDir string //GetLastCommitHashLocal
63+
Hash string //GetLastCommitHash or GetLastCommitHashLocal
64+
UpdateCommand string //go get -x gioui.org@hash
6165
}
6266

63-
var m = safemap.NewOrdered[string, string](func(yield func(string, string) bool) {
64-
yield("https://github.com/gioui/gio", "")
67+
var m = safemap.NewOrdered[string, ModInfo](func(yield func(string, ModInfo) bool) {
68+
yield("https://github.com/gioui/gio", ModInfo{
69+
ModName: "gioui.org",
70+
RepositoryUrl: "https://github.com/gioui/gio",
71+
repositoryDir: "",
72+
Hash: "",
73+
UpdateCommand: "",
74+
})
75+
yield("https://github.com/gioui/gio/cmd", ModInfo{
76+
ModName: "gioui.org/cmd",
77+
RepositoryUrl: "https://github.com/gioui/gio/cmd",
78+
repositoryDir: "",
79+
Hash: "",
80+
UpdateCommand: "",
81+
})
82+
yield("https://github.com/gioui/gio/example", ModInfo{
83+
ModName: "gioui.org/example",
84+
RepositoryUrl: "https://github.com/gioui/gio/example",
85+
repositoryDir: "",
86+
Hash: "",
87+
UpdateCommand: "",
88+
})
89+
yield("https://github.com/gioui/gio/x", ModInfo{
90+
ModName: "gioui.org/x",
91+
RepositoryUrl: "https://github.com/gioui/gio/x",
92+
repositoryDir: "",
93+
Hash: "",
94+
UpdateCommand: "",
95+
})
96+
yield("https://github.com/oligo/gvcode", ModInfo{
97+
ModName: "github.com/oligo/gvcode",
98+
RepositoryUrl: "https://github.com/oligo/gvcode",
99+
repositoryDir: "",
100+
Hash: "",
101+
UpdateCommand: "",
102+
})
103+
yield("https://github.com/ddkwork/golibrary", ModInfo{
104+
ModName: "github.com/ddkwork/golibrary",
105+
RepositoryUrl: "https://github.com/ddkwork/golibrary",
106+
repositoryDir: "",
107+
Hash: "",
108+
UpdateCommand: "",
109+
})
110+
yield("https://github.com/ddkwork/ux", ModInfo{
111+
ModName: "github.com/ddkwork/ux",
112+
RepositoryUrl: "https://github.com/ddkwork/ux",
113+
repositoryDir: "",
114+
Hash: "",
115+
UpdateCommand: "",
116+
})
117+
yield("https://github.com/google/go-cmp", ModInfo{
118+
ModName: "github.com/google/go-cmp",
119+
RepositoryUrl: "https://github.com/google/go-cmp",
120+
repositoryDir: "",
121+
Hash: "",
122+
UpdateCommand: "",
123+
})
124+
yield("https://github.com/ddkwork/app", ModInfo{
125+
ModName: "github.com/ddkwork/app",
126+
RepositoryUrl: "https://github.com/ddkwork/app",
127+
repositoryDir: "",
128+
Hash: "",
129+
UpdateCommand: "",
130+
})
131+
yield("https://github.com/ddkwork/toolbox", ModInfo{
132+
ModName: "github.com/ddkwork/toolbox",
133+
RepositoryUrl: "https://github.com/ddkwork/toolbox",
134+
repositoryDir: "",
135+
Hash: "",
136+
UpdateCommand: "",
137+
})
138+
yield("https://github.com/ddkwork/unison", ModInfo{
139+
ModName: "github.com/ddkwork/unison",
140+
RepositoryUrl: "https://github.com/ddkwork/unison",
141+
repositoryDir: "",
142+
Hash: "",
143+
UpdateCommand: "",
144+
})
145+
yield("https://github.com/ebitengine/purego", ModInfo{
146+
ModName: "github.com/ebitengine/purego",
147+
RepositoryUrl: "https://github.com/ebitengine/purego",
148+
repositoryDir: "",
149+
Hash: "",
150+
UpdateCommand: "",
151+
})
152+
yield("https://github.com/saferwall/pe", ModInfo{
153+
ModName: "github.com/saferwall/pe",
154+
RepositoryUrl: "https://github.com/saferwall/pe",
155+
repositoryDir: "",
156+
Hash: "",
157+
UpdateCommand: "",
158+
})
159+
65160
})
66161

67162
func GetLastCommitHashLocal(repositoryName, repositoryDir string) string {
@@ -137,7 +232,7 @@ func updateModsByWorkSpace(isUpdateAll bool) {
137232
mylog.Check(os.Chdir(mod))
138233
UpdateDependencies()
139234
if isUpdateAll {
140-
RunCommand("go get -v -u all")
235+
RunCommand("go get -u -x all")
141236
}
142237
modChan <- mod
143238
return nil

stream/gen.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,22 @@ func (g *GeneratedFile) PC(is64Bit bool, v string) {
6262
g.P(g.callBack(is64Bit, v))
6363
}
6464

65+
func (g *GeneratedFile) PKeepSpace(v ...any) { //for gen github action yml file
66+
g.p(true, v...)
67+
}
68+
6569
func (g *GeneratedFile) P(v ...any) {
70+
g.p(false, v...)
71+
}
72+
73+
func (g *GeneratedFile) p(keepSpace bool, v ...any) {
6674
for _, x := range v {
6775
s, ok := x.(string)
6876
if ok {
6977
if strings.Contains(s, "\n") {
70-
s = strings.TrimSpace(s)
78+
if !keepSpace {
79+
s = strings.TrimSpace(s)
80+
}
7181
s = strings.TrimPrefix(s, "\n")
7282
x = s
7383
}

0 commit comments

Comments
 (0)