Skip to content

Commit

Permalink
allow that one can choose a different owner name for github
Browse files Browse the repository at this point in the history
This way one can choose a long (the proper) name as owner and then
define the github organisation name
  • Loading branch information
robstoll committed Mar 7, 2024
1 parent a586905 commit d953784
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/.github/Contributor Agreement.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ which was based in turn on the Harmony contributor agreements harmonyagreements.
Thank you for your interest in contributing to
<PROJECT_NAME>
currently developed on the platform
https://github.com/tegonal/<PROJECT_NAME>
https://github.com/<OWNER_GITHUB>/<PROJECT_NAME_GITHUB>
and owned by
<OWNER> (the “Project Owner”, hereafter "We" or "Us").

Expand Down
43 changes: 26 additions & 17 deletions src/gt/pull-hook-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,60 @@ fi

sourceOnce "$dir_of_tegonal_scripts/utility/parse-fn-args.sh"

function replaceTegonalGhCommonsPlaceholders(){
local source projectName version owner ownerEmail ownerGithubName projectNameGithub
function replaceTegonalGhCommonsPlaceholders() {
local source projectName version owner ownerEmail ownerGithub projectNameGithub
# shellcheck disable=SC2034 # is passed to parseFnArgs by name
local -ra params=(source projectName version owner ownerEmail ownerGithubName projectNameGithub)
local -ra params=(source projectName version owner ownerEmail ownerGithub projectNameGithub)
parseFnArgs params "$@"

if [[ $source =~ .*/\.github/CODE_OF_CONDUCT.md ]]; then
replacePlaceholdersCodeOfConduct "$source" "$ownerEmail"
replacePlaceholdersCodeOfConduct "$source" "$ownerEmail"
elif [[ $source =~ .*/\.github/Contributor[[:space:]]Agreement\.txt ]]; then
replacePlaceholdersContributorsAgreement "$source" "$projectName" "$owner"
replacePlaceholdersContributorsAgreement "$source" "$projectName" "$projectNameGithub" "$owner" "$ownerGithub"
elif [[ $source =~ .*/\.github/PULL_REQUEST_TEMPLATE.md ]]; then
local -r githubUrl="https://github.com/$ownerGithubName/$projectNameGithub"
local -r githubUrl="https://github.com/$ownerGithub/$projectNameGithub"
replacePlaceholdersPullRequestTemplate "$source" "$githubUrl" "$version"
fi
}

function replaceTegonalGhCommonsPlaceholders_Tegonal(){
function replaceTegonalGhCommonsPlaceholders_Tegonal() {
local source projectName version projectNameGithub
# shellcheck disable=SC2034 # is passed to parseFnArgs by name
local -ra params=(source projectName version projectNameGithub)
parseFnArgs params "$@"


local tegonalFullName tegonalEmail tegonalGithubName
source "$dir_of_github_commons/gt/tegonal.data.source.sh" || die "could not source tegonal.data.source.sh"

replaceTegonalGhCommonsPlaceholders "$source" "$projectName" "$version" "$tegonalFullName" "$tegonalEmail" "$tegonalGithubName" "$projectNameGithub"
}

function replacePlaceholdersContributorsAgreement() {
if ! (($# == 3)); then
logError "you need to pass three arguments to replacePlaceholdersContributorsAgreement"
echo "1: file represents the 'Contributor Agreement.txt'"
echo "2: projectName the name of the project"
echo "3: owner owner of the project"
if ! (($# == 5)); then
logError "you need to pass 5 arguments to replacePlaceholdersContributorsAgreement"
echo "1: file represents the 'Contributor Agreement.txt'"
echo "2: projectName the name of the project"
echo "3: projectNameGithub the name of the project on GitHub"
echo "4: owner the owner of the project"
echo "5: ownerGithub the name of the organisation/owner on GitHub"
printStackTrace
exit 9
fi
local -r file=$1
local -r projectName=$2
local -r owner=$3
shift 3 || die "could not shift by 3"
PROJECT_NAME="$projectName" OWNER="$owner" perl -0777 -i \
local -r projectNameGithub=$3
local -r owner=$4
local -r ownerGithub=$5
shift 5 || die "could not shift by 5"
PROJECT_NAME="$projectName" \
PROJECT_NAME_GITHUB="$projectNameGithub" \
OWNER="$owner" \
OWNER_GITHUB="$ownerGithub" \
perl -0777 -i \
-pe 's/<PROJECT_NAME>/$ENV{PROJECT_NAME}/g;' \
-pe 's/<PROJECT_NAME_GITHUB>/$ENV{PROJECT_NAME_GITHUB}/g;' \
-pe 's/<OWNER>/$ENV{OWNER}/g;' \
-pe 's/<OWNER_GITHUB>/$ENV{OWNER_GITHUB}/g;' \
"$file"
}

Expand All @@ -120,7 +129,7 @@ function replacePlaceholdersPullRequestTemplate() {
"$file"
}

function replacePlaceholdersCodeOfConduct(){
function replacePlaceholdersCodeOfConduct() {
if ! (($# == 2)); then
logError "you need to pass two arguments to replacePlaceholdersCodeOfConductTemplate"
echo "1: file represents the 'CODE_OF_CONDUCT.md'"
Expand Down

0 comments on commit d953784

Please sign in to comment.