summaryrefslogtreecommitdiff
path: root/patchset.Send.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-11 02:20:06 -0500
committerJeff Carr <[email protected]>2025-09-11 02:20:06 -0500
commit98467dec72f0a894b7a2fef319d73d3320d94d0f (patch)
tree2bbd2f2fb9d50b413e716ca7030304f950c65194 /patchset.Send.go
parentdbde2f51b8acb4043203b5592531c6715896c800 (diff)
using new config package
Diffstat (limited to 'patchset.Send.go')
-rw-r--r--patchset.Send.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/patchset.Send.go b/patchset.Send.go
index eaac09e..1601663 100644
--- a/patchset.Send.go
+++ b/patchset.Send.go
@@ -5,6 +5,8 @@ package forgepb
import (
"errors"
+ "os"
+ "path/filepath"
"strings"
"time"
@@ -137,3 +139,32 @@ func (f *Forge) SubmitPatchesNew(pset *Patches, urlpath string) (*Patches, error
log.Info("Total patches sent ok:", newpb.Len())
return newpb, nil
}
+
+func loadFile(filename string) ([]byte, error) {
+ fullname := filepath.Join(os.Getenv("FORGE_CONFIG"), filename)
+ data, err := os.ReadFile(fullname)
+ if errors.Is(err, os.ErrNotExist) {
+ // if file does not exist, just return nil. this
+ // will cause ConfigLoad() to try the next config file like "forge.text"
+ // because the user might want to edit the .config by hand
+ return nil, nil
+ }
+ if err != nil {
+ // log.Info("open config file :", err)
+ return nil, err
+ }
+ return data, nil
+}
+
+func configWrite(filename string, data []byte) error {
+ fullname := filepath.Join(os.Getenv("FORGE_CONFIG"), filename)
+
+ cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
+ defer cfgfile.Close()
+ if err != nil {
+ log.Warn("open config file :", err)
+ return err
+ }
+ cfgfile.Write(data)
+ return nil
+}