1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Support async gitops

This commit is contained in:
bouncepaw 2020-09-29 23:13:24 +05:00
parent 00bc9d4b17
commit 3a1d1c2ce2
4 changed files with 10 additions and 4 deletions

View File

@ -4,9 +4,9 @@ A wiki engine.
## 0.9
This is a development branch for 0.9 version. Features I want to implement in this release:
* [x] Recent changes page.
* [ ] Hypha deletion.
* [x] Hypha deletion.
* [ ] Hypha renaming.
* [ ] Support async git ops.
* [x] Support async git ops.
## Installation
```sh

View File

@ -99,10 +99,10 @@ func init() {
}
// I pronounce it as [gɪt͡ʃ].
// gitsh is async-safe, therefore all other git-related functions in this module are too.
func gitsh(args ...string) (out bytes.Buffer, err error) {
fmt.Printf("$ %v\n", args)
cmd := exec.Command(gitpath, args...)
cmd.Dir = util.WikiDir
b, err := cmd.CombinedOutput()

View File

@ -4,10 +4,14 @@ package history
import (
"fmt"
"sync"
"github.com/bouncepaw/mycorrhiza/util"
)
// gitMutex is used for blocking git operations to avoid clashes.
var gitMutex = sync.Mutex{}
// OpType is the type a history operation has. Callers shall set appropriate optypes when creating history operations.
type OpType int
@ -31,6 +35,7 @@ type HistoryOp struct {
// Operation is a constructor of a history operation.
func Operation(opType OpType) *HistoryOp {
gitMutex.Lock()
hop := &HistoryOp{
Errs: []error{},
opType: opType,
@ -75,6 +80,7 @@ func (hop *HistoryOp) Apply() *HistoryOp {
"--author='"+hop.name+" <"+hop.email+">'",
"--message="+hop.userMsg,
)
gitMutex.Unlock()
return hop
}

@ -1 +1 @@
Subproject commit ecaa76f841afcb3514b7061eb6708092bc17ee08
Subproject commit 2c0e43199ed28f7022a38463a0eec3af3ecb03c9