-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commands: fix refs 'edges' option work #3007
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,17 +74,26 @@ NOTE: List all references recursively by using the flag '-r'. | |
return | ||
} | ||
|
||
edges, _, err := req.Option("edges").Bool() | ||
format, _, err := req.Option("format").String() | ||
if err != nil { | ||
res.SetError(err, cmds.ErrNormal) | ||
return | ||
} | ||
|
||
format, _, err := req.Option("format").String() | ||
edges, _, err := req.Option("edges").Bool() | ||
if err != nil { | ||
res.SetError(err, cmds.ErrNormal) | ||
return | ||
} | ||
if edges { | ||
if format != "<dst>" { | ||
res.SetError(errors.New("using format arguement with edges is not allowed"), | ||
cmds.ErrClient) | ||
return | ||
} | ||
|
||
format = "<src> -> <dst>" | ||
} | ||
|
||
objs, err := objectsForPaths(ctx, n, req.Arguments()) | ||
if err != nil { | ||
|
@@ -103,7 +112,6 @@ NOTE: List all references recursively by using the flag '-r'. | |
DAG: n.DAG, | ||
Ctx: ctx, | ||
Unique: unique, | ||
PrintEdge: edges, | ||
PrintFmt: format, | ||
Recursive: recursive, | ||
} | ||
|
@@ -210,7 +218,6 @@ type RefWriter struct { | |
|
||
Unique bool | ||
Recursive bool | ||
PrintEdge bool | ||
PrintFmt string | ||
|
||
seen map[key.Key]struct{} | ||
|
@@ -315,8 +322,6 @@ func (rw *RefWriter) WriteEdge(from, to key.Key, linkname string) error { | |
s = strings.Replace(s, "<src>", from.B58String(), -1) | ||
s = strings.Replace(s, "<dst>", to.B58String(), -1) | ||
s = strings.Replace(s, "<linkname>", linkname, -1) | ||
case rw.PrintEdge: | ||
s = from.B58String() + " -> " + to.B58String() | ||
default: | ||
s += to.B58String() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this default case? It would only trigger if |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't
format
be an empty string (rather than"<dst>"
) if it isn't provided?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no because:
.Default("<dst>")