@@ -124,41 +124,43 @@ func generateRepoCommit(e Engine, repo, templateRepo, generateRepo *Repository,
124
124
return fmt .Errorf ("checkGiteaTemplate: %v" , err )
125
125
}
126
126
127
- if err := os .Remove (gt .Path ); err != nil {
128
- return fmt .Errorf ("remove .giteatemplate: %v" , err )
129
- }
130
-
131
- // Avoid walking tree if there are no globs
132
- if len (gt .Globs ()) > 0 {
133
- tmpDirSlash := strings .TrimSuffix (filepath .ToSlash (tmpDir ), "/" ) + "/"
134
- if err := filepath .Walk (tmpDirSlash , func (path string , info os.FileInfo , walkErr error ) error {
135
- if walkErr != nil {
136
- return walkErr
137
- }
127
+ if gt != nil {
128
+ if err := os .Remove (gt .Path ); err != nil {
129
+ return fmt .Errorf ("remove .giteatemplate: %v" , err )
130
+ }
138
131
139
- if info .IsDir () {
140
- return nil
141
- }
132
+ // Avoid walking tree if there are no globs
133
+ if len (gt .Globs ()) > 0 {
134
+ tmpDirSlash := strings .TrimSuffix (filepath .ToSlash (tmpDir ), "/" ) + "/"
135
+ if err := filepath .Walk (tmpDirSlash , func (path string , info os.FileInfo , walkErr error ) error {
136
+ if walkErr != nil {
137
+ return walkErr
138
+ }
142
139
143
- base := strings .TrimPrefix (filepath .ToSlash (path ), tmpDirSlash )
144
- for _ , g := range gt .Globs () {
145
- if g .Match (base ) {
146
- content , err := ioutil .ReadFile (path )
147
- if err != nil {
148
- return err
149
- }
140
+ if info .IsDir () {
141
+ return nil
142
+ }
150
143
151
- if err := ioutil .WriteFile (path ,
152
- []byte (generateExpansion (string (content ), templateRepo , generateRepo )),
153
- 0644 ); err != nil {
154
- return err
144
+ base := strings .TrimPrefix (filepath .ToSlash (path ), tmpDirSlash )
145
+ for _ , g := range gt .Globs () {
146
+ if g .Match (base ) {
147
+ content , err := ioutil .ReadFile (path )
148
+ if err != nil {
149
+ return err
150
+ }
151
+
152
+ if err := ioutil .WriteFile (path ,
153
+ []byte (generateExpansion (string (content ), templateRepo , generateRepo )),
154
+ 0644 ); err != nil {
155
+ return err
156
+ }
157
+ break
155
158
}
156
- break
157
159
}
160
+ return nil
161
+ }); err != nil {
162
+ return err
158
163
}
159
- return nil
160
- }); err != nil {
161
- return err
162
164
}
163
165
}
164
166
0 commit comments