diff options
Diffstat (limited to 'lib/pama/init.go')
-rw-r--r-- | lib/pama/init.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/pama/init.go b/lib/pama/init.go new file mode 100644 index 00000000..cfb9c896 --- /dev/null +++ b/lib/pama/init.go @@ -0,0 +1,34 @@ +package pama + +import ( + "git.sr.ht/~rjarry/aerc/lib/pama/models" +) + +// Init creats a new revision control project +func (m PatchManager) Init(name, path string, overwrite bool) error { + id, root, err := m.detect(path) + if err != nil { + return err + } + rc, err := m.rc(id, root) + if err != nil { + return err + } + headID, err := rc.Head() + if err != nil { + return err + } + p := models.Project{ + Name: name, + Root: root, + RevctrlID: id, + Base: models.NewCommit(rc, headID, ""), + Commits: make([]models.Commit, 0), + } + store := m.store() + err = store.StoreProject(p, overwrite) + if err != nil { + return storeErr(err) + } + return storeErr(store.SetCurrent(name)) +} |