Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reference-repository
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
grid5000
reference-repository
Commits
7d3c464f
Commit
7d3c464f
authored
7 years ago
by
Florent Didier
Browse files
Options
Downloads
Patches
Plain Diff
[dev] wiki_generator.rb: add diff_files method
parent
febfda55
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
generators/wiki/mw_utils.rb
+17
-0
17 additions, 0 deletions
generators/wiki/mw_utils.rb
generators/wiki/wiki_generator.rb
+24
-1
24 additions, 1 deletion
generators/wiki/wiki_generator.rb
with
41 additions
and
1 deletion
generators/wiki/mw_utils.rb
+
17
−
0
View file @
7d3c464f
...
@@ -28,6 +28,23 @@ module MediawikiApi
...
@@ -28,6 +28,23 @@ module MediawikiApi
res
=
get_conn
.
send
(
:get
,
''
,
params
)
res
=
get_conn
.
send
(
:get
,
''
,
params
)
res
.
body
res
.
body
end
end
def
get_file_content
(
file_name
)
get_conn
=
Faraday
.
new
(
url:
MW
::
BASE_URL
+
"images/
#{
file_name
}
"
)
do
|
faraday
|
faraday
.
request
:multipart
faraday
.
request
:url_encoded
faraday
.
use
:cookie_jar
,
jar:
@cookies
faraday
.
use
FaradayMiddleware
::
FollowRedirects
faraday
.
adapter
Faraday
.
default_adapter
end
params
=
{
:token_type
=>
false
,
:action
=>
'raw'
}
params
[
:token
]
=
get_token
(
:csrf
)
res
=
get_conn
.
send
(
:get
,
''
,
params
)
res
.
body
end
def
update_file
(
filename
,
path
,
content_type
,
comment
,
ignorewarnings
,
text
=
nil
)
def
update_file
(
filename
,
path
,
content_type
,
comment
,
ignorewarnings
,
text
=
nil
)
file
=
Faraday
::
UploadIO
.
new
(
path
,
content_type
)
file
=
Faraday
::
UploadIO
.
new
(
path
,
content_type
)
...
...
This diff is collapsed.
Click to expand it.
generators/wiki/wiki_generator.rb
+
24
−
1
View file @
7d3c464f
...
@@ -53,6 +53,28 @@ class WikiGenerator
...
@@ -53,6 +53,28 @@ class WikiGenerator
}
}
end
end
def
diff_files
ret
=
true
@files
.
each
{
|
file
|
if
file
[
'content-type'
]
==
'text/plain'
file_content
=
@mw_client
.
get_file_content
(
file
[
'filename'
])
generated_content
=
File
.
read
(
file
[
'path'
])
diff
=
Diffy
::
Diff
.
new
(
file_content
,
generated_content
,
:context
=>
0
)
if
(
diff
.
to_s
.
empty?
)
puts
"No differences found between generated and current content for file
#{
file
[
'filename'
]
}
."
ret
&=
true
else
puts
"Differences between generated and current content for file
#{
file
[
'filename'
]
}
:"
puts
'------------ FILE DIFF BEGIN ------------'
puts
"
#{
diff
.
to_s
(
:text
)
}
"
puts
'------------- FILE DIFF END -------------'
ret
&=
false
end
end
}
return
ret
end
#print generator content to stdout
#print generator content to stdout
def
print
()
def
print
()
puts
@generated_content
puts
@generated_content
...
@@ -117,7 +139,8 @@ class WikiGenerator
...
@@ -117,7 +139,8 @@ class WikiGenerator
generator
.
login
(
options
)
generator
.
login
(
options
)
end
end
if
(
options
[
:diff
])
if
(
options
[
:diff
])
generator
.
diff_page
generator
.
diff_page
if
generator
.
instance_variable_get
(
'@generated_content'
)
generator
.
diff_files
if
generator
.
instance_variable_get
(
'@files'
)
end
end
if
(
options
[
:print
])
if
(
options
[
:print
])
generator
.
print
generator
.
print
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment