Branch/fork-aware Edit on GitHub links (2/2)

(Thrice-amended commit with proper bash syntax)
This commit is contained in:
mDuo13
2018-03-07 15:03:27 -08:00
parent 560c84f4f9
commit 5cd91c6f21
4 changed files with 29 additions and 12 deletions

View File

@@ -42,12 +42,12 @@ targets:
display_name: Ripple Developer Portal display_name: Ripple Developer Portal
# These github_ fields are used by the template's "Edit on GitHub" link. # These github_ fields are used by the template's "Edit on GitHub" link.
# Override them with --vars to change which fork/branch to edit. # Override them with --vars to change which fork/branch to edit.
github_fork: ripple github_forkurl: https://github.com/ripple/ripple-dev-portal/
github_branch: master github_branch: master
- name: ripple.com - name: ripple.com
display_name: Ripple Developer Center display_name: Ripple Developer Center
github_fork: ripple github_forkurl: https://github.com/ripple/ripple-dev-portal/
github_branch: master github_branch: master
template: template-contentwithtoc.html template: template-contentwithtoc.html
link_subs: link_subs:

View File

@@ -1,7 +1,11 @@
#!/bin/bash #!/bin/bash
mkdir -p out mkdir -p out
## One-liner syntax doesn't handle exit codes properly...
#./build.sh -lq | awk '{print "rm -r out/ && ./build.sh -t "$1" && ./check-links.sh"}' | xargs -0 bash -c # Pass forward extra dactyl args if provided
if [ -n "$1" ];
then
dactyl_args=$1
fi
targets=`dactyl_build -lq | awk '{print $1}'` targets=`dactyl_build -lq | awk '{print $1}'`
linkerrors=0 linkerrors=0
@@ -11,7 +15,7 @@ while read -r line; do
echo "=======================================" echo "======================================="
echo "Checking Target: $line" echo "Checking Target: $line"
rm -r out rm -r out
dactyl_build -sq -t "$line" dactyl_build -sq -t "$line" "$dactyl_args"
buildresult=$? buildresult=$?
if [ $buildresult -eq 0 ] if [ $buildresult -eq 0 ]
then then

View File

@@ -7,7 +7,16 @@ echo "ghprbAuthorRepoGitUrl is: " ${ghprbAuthorRepoGitUrl}
echo "ghprbSourceBranch is: " ${ghprbSourceBranch} echo "ghprbSourceBranch is: " ${ghprbSourceBranch}
echo "ghprbPullId is: " ${ghprbPullId} echo "ghprbPullId is: " ${ghprbPullId}
gitForkWithoutSuffix=${ghprbAuthorRepoGitUrl%.git}
if [ -n "$ghprbPullId" ];
then
dactyl_vars='--vars '"'"'{"github_forkurl": "'"$gitForkWithoutSuffix"'", "github_branch": "'"$ghprbSourceBranch"'", "github_pr_id": "'"$ghprbPullId"'"}'"'"
else
dactyl_vars=""
fi
set -e set -e
tool/conflictmarkers.sh tool/conflictmarkers.sh
tool/all-target-link-checker.sh tool/all-target-link-checker.sh "$dactyl_vars"

View File

@@ -55,15 +55,19 @@
<div class="draft-warning">DRAFT PAGE</div> <div class="draft-warning">DRAFT PAGE</div>
<div class="github-edit-wrap"> <div class="github-edit-wrap">
{% if currentpage.md is defined %} {% if currentpage.md is defined %}
{% set githuburl = "https://github.com/" {% set githuburl = target.github_forkurl + "/edit/"
+ target.github_fork + "/ripple-dev-portal/edit/" + target.github_branch
+ target.github_branch + "/content/" + currentpage.md %} + "/content/" + currentpage.md %}
{% endif %}
{% elif currentpage.template is defined %} {% elif currentpage.template is defined %}
{% set githuburl = "https://github.com/" {% set githuburl = target.github_forkurl + "/edit/"
+ target.github_fork + "/ripple-dev-portal/edit/"
+ target.github_branch + "/tool/" + currentpage.template %} + target.github_branch + "/tool/" + currentpage.template %}
{% else %} {% else %}
{% set githuburl = "https://github.com/ripple/ripple-dev-portal/" %} {% set githuburl = target.github_forkurl %}
{% endif %}
{% if target.is_pr_build %}
{% set githuburl = githuburl + "?pr=/ripple/ripple-dev-portal/pull/"
+ target.github_pr_id %}
{% endif %} {% endif %}
<a href="{{githuburl}}" class="github-edit">Edit on GitHub</a> <a href="{{githuburl}}" class="github-edit">Edit on GitHub</a>
</div><!-- /.github-edit --> </div><!-- /.github-edit -->