Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Privacy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
x2004933
Privacy
Commits
a30b335b
Commit
a30b335b
authored
4 years ago
by
x2004933
Browse files
Options
Downloads
Patches
Plain Diff
Add diffs to pages
parent
d5bbc8f1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
pages.sh
+18
-4
18 additions, 4 deletions
pages.sh
with
20 additions
and
5 deletions
.gitattributes
0 → 100644
+
1
−
0
View file @
a30b335b
*.html diff=pandoc
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
1
−
1
View file @
a30b335b
image
:
alpine
before_script
:
-
apk add git sed bash
-
apk add git sed bash
pandoc
pages_test
:
stage
:
test
...
...
This diff is collapsed.
Click to expand it.
pages.sh
+
18
−
4
View file @
a30b335b
...
...
@@ -7,7 +7,10 @@ pages_dir="public"
template
=
"index.html"
links
=
""
mkdir
"
${
pages_dir
}
"
mkdir
-p
"
${
pages_dir
}
"
# Set the diff tool
git config diff.pandoc.textconv
'pandoc -t gfm'
# Get the relevant commits from the log
commits
=
$(
git log
--pretty
=
oneline |
grep
"Update at"
|
cut
-d
' '
-f1
)
...
...
@@ -16,21 +19,32 @@ commits=$(git log --pretty=oneline | grep "Update at" | cut -d' ' -f1)
for
c
in
$commits
do
# Checkout the relevant commit
git checkout
"
$c
"
git checkout
"
$c
"
--
"
${
site_dir
}
"
# Get the date of the commit
date
=
$(
git show
-s
--format
=
%ai
"
$c
"
)
# Show the latest commit
git diff
"
$c
~1"
"
$c
"
--
"
${
site_dir
}
"
>
"
${
pages_dir
}
/
${
c
}
.diff.txt"
# Check if commit is empty
if
[[
-s
"
${
pages_dir
}
/
${
c
}
.diff.txt"
]]
then
diff
=
"<a href=
\"
${
c
}
.diff.txt
\"
>diff</a>"
else
diff
=
"no changes"
fi
# Copy the state of the site to the pages dir
cp
-a
"
${
site_dir
}
"
"
${
pages_dir
}
/
${
date
}
"
# Add a link to the index
links
=
"
${
links
}
<li><a href=
\"
${
date
}
/
${
main_dir
}
\"
>
${
date
}
</a></li>"
links
=
"
${
links
}
<li><a href=
\"
${
date
}
/
${
main_dir
}
\"
>
${
date
}
</a>
(
${
diff
}
)
</li>"
# Create a 'latest' symlink for the latest commit
[
!
-e
"
${
pages_dir
}
/latest"
]
&&
ln
-s
"
${
date
}
"
"
${
pages_dir
}
/latest"
done
git checkout master
git checkout master
--
site/
# Create index file
sed
"s|{{body}}|
${
links
}
|g"
"
${
template
}
"
>
"
${
pages_dir
}
/index.html"
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