Move ParsePrefix into common code. #116

This commit is contained in:
Andrey Smirnov
2014-12-23 00:50:28 +03:00
parent 923e2e1e50
commit d586f31247
6 changed files with 20 additions and 19 deletions
-15
View File
@@ -4,7 +4,6 @@ import (
"github.com/smira/aptly/utils"
"github.com/smira/commander"
"github.com/smira/flag"
"strings"
)
func getSigner(flags *flag.FlagSet) (utils.Signer, error) {
@@ -27,20 +26,6 @@ func getSigner(flags *flag.FlagSet) (utils.Signer, error) {
}
func parsePrefix(param string) (storage, prefix string) {
i := strings.LastIndex(param, ":")
if i != -1 {
storage = param[:i]
prefix = param[i+1:]
if prefix == "" {
prefix = "."
}
} else {
prefix = param
}
return
}
func makeCmdPublish() *commander.Command {
return &commander.Command{
UsageLine: "publish",
+2 -1
View File
@@ -2,6 +2,7 @@ package cmd
import (
"fmt"
"github.com/smira/aptly/deb"
"github.com/smira/commander"
)
@@ -19,7 +20,7 @@ func aptlyPublishDrop(cmd *commander.Command, args []string) error {
param = args[1]
}
storage, prefix := parsePrefix(param)
storage, prefix := deb.ParsePrefix(param)
err = context.CollectionFactory().PublishedRepoCollection().Remove(context, storage, prefix, distribution,
context.CollectionFactory(), context.Progress())
+1 -1
View File
@@ -27,7 +27,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
} else {
param = ""
}
storage, prefix := parsePrefix(param)
storage, prefix := deb.ParsePrefix(param)
var (
sources = []interface{}{}
+1 -1
View File
@@ -33,7 +33,7 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
names = args[1:]
}
storage, prefix := parsePrefix(param)
storage, prefix := deb.ParsePrefix(param)
var published *deb.PublishedRepo
+1 -1
View File
@@ -20,7 +20,7 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
if len(args) == 2 {
param = args[1]
}
storage, prefix := parsePrefix(param)
storage, prefix := deb.ParsePrefix(param)
var published *deb.PublishedRepo