mirror of https://github.com/databricks/cli.git
Move diff struct to its own file (#175)
This commit is contained in:
parent
015a2bf9bb
commit
c777a703cf
|
@ -0,0 +1,29 @@
|
||||||
|
package sync
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type diff struct {
|
||||||
|
put []string
|
||||||
|
delete []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d diff) IsEmpty() bool {
|
||||||
|
return len(d.put) == 0 && len(d.delete) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d diff) String() string {
|
||||||
|
if d.IsEmpty() {
|
||||||
|
return "no changes"
|
||||||
|
}
|
||||||
|
var changes []string
|
||||||
|
if len(d.put) > 0 {
|
||||||
|
changes = append(changes, fmt.Sprintf("PUT: %s", strings.Join(d.put, ", ")))
|
||||||
|
}
|
||||||
|
if len(d.delete) > 0 {
|
||||||
|
changes = append(changes, fmt.Sprintf("DELETE: %s", strings.Join(d.delete, ", ")))
|
||||||
|
}
|
||||||
|
return strings.Join(changes, ", ")
|
||||||
|
}
|
|
@ -66,11 +66,6 @@ type Snapshot struct {
|
||||||
RemoteToLocalNames map[string]string `json:"remote_to_local_names"`
|
RemoteToLocalNames map[string]string `json:"remote_to_local_names"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type diff struct {
|
|
||||||
put []string
|
|
||||||
delete []string
|
|
||||||
}
|
|
||||||
|
|
||||||
const syncSnapshotDirName = "sync-snapshots"
|
const syncSnapshotDirName = "sync-snapshots"
|
||||||
|
|
||||||
func GetFileName(host, remotePath string) string {
|
func GetFileName(host, remotePath string) string {
|
||||||
|
@ -170,24 +165,6 @@ func loadOrNewSnapshot(opts *SyncOptions) (*Snapshot, error) {
|
||||||
return snapshot, nil
|
return snapshot, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d diff) IsEmpty() bool {
|
|
||||||
return len(d.put) == 0 && len(d.delete) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d diff) String() string {
|
|
||||||
if d.IsEmpty() {
|
|
||||||
return "no changes"
|
|
||||||
}
|
|
||||||
var changes []string
|
|
||||||
if len(d.put) > 0 {
|
|
||||||
changes = append(changes, fmt.Sprintf("PUT: %s", strings.Join(d.put, ", ")))
|
|
||||||
}
|
|
||||||
if len(d.delete) > 0 {
|
|
||||||
changes = append(changes, fmt.Sprintf("DELETE: %s", strings.Join(d.delete, ", ")))
|
|
||||||
}
|
|
||||||
return strings.Join(changes, ", ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func getNotebookDetails(path string) (isNotebook bool, typeOfNotebook string, err error) {
|
func getNotebookDetails(path string) (isNotebook bool, typeOfNotebook string, err error) {
|
||||||
isNotebook = false
|
isNotebook = false
|
||||||
typeOfNotebook = ""
|
typeOfNotebook = ""
|
||||||
|
|
Loading…
Reference in New Issue