blob: 18a93a271b60321a5fd0da53494ad1fa35e644d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package pama
import "fmt"
// Delete removes provided project
func (m PatchManager) Delete(name string) error {
store := m.store()
names, err := m.Names()
if err != nil {
return err
}
index := -1
for i, s := range names {
if s == name {
index = i
break
}
}
if index < 0 {
return fmt.Errorf("Project '%s' not found", name)
}
cur, err := m.CurrentProject()
if err == nil && cur.Name == name {
var next string
for _, s := range names {
if name != s {
next = s
break
}
}
err = store.SetCurrent(next)
if err != nil {
return storeErr(err)
}
}
return storeErr(m.store().DeleteProject(name))
}
func (m PatchManager) Names() ([]string, error) {
names, err := m.store().Names()
return names, storeErr(err)
}
|