Skip to content
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

Changes for good index (and other markdown) rendering on GitLab and Codeberg #401

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions id.mk
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ BRANCH_FETCH := true
endif
export BRANCH_FETCH
ifeq (,$(DEFAULT_BRANCH))
ifeq (github.com,$(GITHUB_HOST))
DEFAULT_BRANCH := $(shell BRANCH_FETCH=$(BRANCH_FETCH) $(LIBDIR)/default-branch.py $(GITHUB_USER) $(GITHUB_REPO) $(GITHUB_API_TOKEN))
else
# default-branch.py recognition only works on GitHub; on other hosters it needs
# to be set manually (also around setup.mk!), or they just use the default
# value.
DEFAULT_BRANCH := main
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEFAULT_BRANCH := main
DEFAULT_BRANCH ?= main

endif
endif
export DEFAULT_BRANCH

Expand Down
48 changes: 34 additions & 14 deletions setup-readme.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
#!/usr/bin/env bash

# Usage: $0 <user> <repo> [draftxml ...]

user="$1"
repo="$2"
# Usage: $0 github.com <user> <repo> [draftxml ...]

host="$1"
user="$2"
repo="$3"
# This is not overridden for non-github hosts because the typical way this is
# called is through setup.mk anyway, which exports DEFAULT_BRANCH
# unconditionally
default_branch="${DEFAULT_BRANCH:-$("$(dirname "$0")/default-branch.py")}"
shift 2

githubio="https://${user}.github.io/${repo}/#go"
shift 3

case "$host" in
codeberg.org)
src_base="https://${host}/${user}/${repo}/src/branch/${default_branch}/"
hostpages="codeberg.page"
;;
github.com)
src_base="https://${host}/${user}/${repo}/blob/${default_branch}/"
hostpages="github.io"
;;
gitlab.com)
src_base="https://${host}/${user}/${repo}/-/blob/${default_branch}/"
hostpages="gitlab.io"
;;
*)
src_base="./"
hostpages="pages.${host}"
;;
esac

githubio="https://${user}.${hostpages}/${repo}/#go"

function fixup_other_md() {
markdown=(LICENSE.md CONTRIBUTING.md)
s='s~{WG_NAME}~'"$1"'~g'
s="$s"';s~{GITHUB_USER}~'"$user"'~g'
s="$s"';s~{GITHUB_REPO}~'"$repo"'~g'
s="$s"';s~{GITHUB_BRANCH}~'"$default_branch"'~g'
s="$s"';s~{SRC_BASE}~'"$src_base"'~g'
sed -i~ -e "$s" "${markdown[@]}"
for i in "${markdown[@]}"; do
rm -f "$i"~
Expand Down Expand Up @@ -82,10 +102,10 @@ cat <<EOF
## Contributing

See the
[guidelines for contributions](https://github.com/${user}/${repo}/blob/${default_branch}/CONTRIBUTING.md).
[guidelines for contributions](${src_base}CONTRIBUTING.md).

Contributions can be made by creating pull requests.
The GitHub interface supports creating pull requests using the Edit (✏) button.
The ${host} interface supports creating pull requests using the Edit (✏) button.


## Command Line Usage
Expand Down Expand Up @@ -127,7 +147,7 @@ Discussion of this work occurs on the [${group_name}
${group_type} mailing list](mailto:${ml})
([archive](${ml_arch}),
[subscribe](${ml_sub})).
In addition to contributions in GitHub, you are encouraged to participate in
In addition to contributions in ${host}, you are encouraged to participate in
discussions there.

**Note**: Some working groups adopt a policy whereby substantive discussion of
Expand Down
2 changes: 1 addition & 1 deletion setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ endif
git add $<

README.md: $(LIBDIR)/setup-readme.sh $(drafts_xml) $(filter %.md, $(TEMPLATE_FILES))
$(LIBDIR)/setup-readme.sh $(GITHUB_USER) $(GITHUB_REPO) $(filter %.xml,$^) >$@
$(LIBDIR)/setup-readme.sh $(GITHUB_HOST) $(GITHUB_USER) $(GITHUB_REPO) $(filter %.xml,$^) >$@
git add $@ $(filter %.md, $(TEMPLATE_FILES))

.PHONY: setup-note
Expand Down
2 changes: 1 addition & 1 deletion template/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# License

See the
[guidelines for contributions](https://github.com/{GITHUB_USER}/{GITHUB_REPO}/blob/{GITHUB_BRANCH}/CONTRIBUTING.md).
[guidelines for contributions]({SRC_BASE}CONTRIBUTING.md).