Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
06435677
Commit
06435677
authored
Jan 19, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19280 from erictune/fix-munge-1
Auto commit by PR queue bot
parents
2a79ac4a
1ce3081e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
mungedocs.go
cmd/mungedocs/mungedocs.go
+6
-2
preformatted.go
cmd/mungedocs/preformatted.go
+1
-1
preformatted_test.go
cmd/mungedocs/preformatted_test.go
+18
-1
No files found.
cmd/mungedocs/mungedocs.go
View file @
06435677
...
@@ -119,8 +119,12 @@ func (f fileProcessor) visit(path string) error {
...
@@ -119,8 +119,12 @@ func (f fileProcessor) visit(path string) error {
}
}
fmt
.
Printf
(
"%s:
\n
"
,
munge
.
name
)
fmt
.
Printf
(
"%s:
\n
"
,
munge
.
name
)
if
*
verbose
{
if
*
verbose
{
fmt
.
Printf
(
"INPUT: <<<%v>>>
\n
"
,
mungeLines
)
if
len
(
mungeLines
)
<=
20
{
fmt
.
Printf
(
"MUNGED: <<<%v>>>
\n
"
,
after
)
fmt
.
Printf
(
"INPUT: <<<%v>>>
\n
"
,
mungeLines
)
fmt
.
Printf
(
"MUNGED: <<<%v>>>
\n
"
,
after
)
}
else
{
fmt
.
Printf
(
"not printing failed chunk: too many lines
\n
"
)
}
}
}
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
...
...
cmd/mungedocs/preformatted.go
View file @
06435677
...
@@ -45,7 +45,7 @@ func updatePreformatted(filePath string, mlines mungeLines) (mungeLines, error)
...
@@ -45,7 +45,7 @@ func updatePreformatted(filePath string, mlines mungeLines) (mungeLines, error)
// If the file ends on a preformatted line, there must have been an imbalance.
// If the file ends on a preformatted line, there must have been an imbalance.
func
checkPreformatBalance
(
filePath
string
,
mlines
mungeLines
)
(
mungeLines
,
error
)
{
func
checkPreformatBalance
(
filePath
string
,
mlines
mungeLines
)
(
mungeLines
,
error
)
{
if
len
(
mlines
)
>
0
&&
mlines
[
len
(
mlines
)
-
1
]
.
preformatted
{
if
len
(
mlines
)
>
0
&&
mlines
[
len
(
mlines
)
-
1
]
.
preformatted
{
return
nil
,
fmt
.
Errorf
(
"file ends in preformatted block
"
)
return
mlines
,
fmt
.
Errorf
(
"unbalanced triple backtick delimiters
"
)
}
}
return
mlines
,
nil
return
mlines
,
nil
}
}
cmd/mungedocs/preformatted_test.go
View file @
06435677
...
@@ -69,12 +69,29 @@ func TestPreformattedImbalance(t *testing.T) {
...
@@ -69,12 +69,29 @@ func TestPreformattedImbalance(t *testing.T) {
}
}
for
i
,
c
:=
range
cases
{
for
i
,
c
:=
range
cases
{
in
:=
getMungeLines
(
c
.
in
)
in
:=
getMungeLines
(
c
.
in
)
_
,
err
:=
checkPreformatBalance
(
"filename.md"
,
in
)
out
,
err
:=
checkPreformatBalance
(
"filename.md"
,
in
)
if
err
!=
nil
&&
c
.
ok
{
if
err
!=
nil
&&
c
.
ok
{
t
.
Errorf
(
"case[%d]: expected success"
,
i
)
t
.
Errorf
(
"case[%d]: expected success"
,
i
)
}
}
if
err
==
nil
&&
!
c
.
ok
{
if
err
==
nil
&&
!
c
.
ok
{
t
.
Errorf
(
"case[%d]: expected failure"
,
i
)
t
.
Errorf
(
"case[%d]: expected failure"
,
i
)
}
}
// Even in case of misformat, return all the text,
// so that the user's work is not lost.
if
!
equalMungeLines
(
out
,
in
)
{
t
.
Errorf
(
"case[%d]: expected munged text to be identical to input text"
,
i
)
}
}
}
func
equalMungeLines
(
a
,
b
mungeLines
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
return
false
}
for
i
:=
range
a
{
if
a
[
i
]
!=
b
[
i
]
{
return
false
}
}
}
return
true
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment