Skip to content

Commit

Permalink
build(kit): install features
Browse files Browse the repository at this point in the history
  • Loading branch information
kit committed Oct 30, 2022
1 parent 68ac71d commit 9ecaf33
Show file tree
Hide file tree
Showing 24 changed files with 800 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/allow-anyone-to-self-assign-an-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Allow anyone to self-assign an issue"

on: [issue_comment]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: bhermann/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
12 changes: 12 additions & 0 deletions .kit/features/0-display-welcome-message/install-into-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

echo "*********************************************************************"
printf "\xF0\x9F\x98\xBA\xF0\x9F\x92\xBB Meow, Kit-tty here!\n"
printf "(I'm in the 'kit' and communicate through your 'tty'\u00B9 - get it? \xF0\x9F\x98\x81)\n"
echo
echo "I am here to help you be successful in the GitKit activities."
echo "You will hear from me every once in a while when I think you"
echo "might need some help."
echo
printf "\u00B9To learn about the tty: https://itsfoss.com/what-is-tty-in-linux/\n"
echo "*********************************************************************"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From d008b798254a94457d7937dccd05e30ca1351ff8 Mon Sep 17 00:00:00 2001
From: Grant Braught <[email protected]>
Date: Fri, 12 Nov 2021 08:43:21 -0500
Subject: [PATCH] Conflicts for practicing merges with conflicts

Students can pull this branch and used it to practice resolving merge conflicts. It contains two merge conflicts with the 4 changes made in the addConflicts branch.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9d26f8e..26c2c3a 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ If you are unfamiliar with [Zulip](https://zulip.com/) it is a group chat applic

### History ###

-FarmData2 is both a _second_ edition of it predecessor, FarmData, and the integration of _two_ related projects FarmData and AnimalData. These projects were conceived and built by Tim Wahls, Matt Steiman and many students to support operation of the Dickinson College Farm. The FarmData2 project was initiated as a part of curricular redesign in the Computer Science Department at Dickinson College. It is now an active part of several courses in the curriculum. It provides students in these courses with early and sustained opportunities to learn and practice modern software development within the context of an open source software community.
+FarmData2 is both a _second_ edition of it predecessor, FarmData, and the integration of _two_ related projects FarmData and AnimalData. These projects were conceived and built by Tim Wahls, Matt Steiman and many students to support operation of the [Dickinson College Farm](https://a.different.link1). The FarmData2 project was initiated as a part of curricular redesign in the Computer Science Department at Dickinson College. It is now an active part of several courses in the curriculum. It provides students in these courses with early and sustained opportunities to learn and practice modern software development within the context of an open source software community.

### Acknowledgements ###

@@ -31,7 +31,7 @@ FarmData2 is powered by the farmOS open source project.
Support and assistance with FarmData2 development has been received from [The Non-Profit FOSS Institute](https://npfi.org/).

The development of FarmData2 has received partial support from:
-* The GNOME Community Engagement Challenge:
+* The [GNOME Community Engagement Challenge](https://a.different.link3):
* [![Phase 1 Badge](media/GNOME-CEC-p1-small.png)](media/GNOME-CEC-p1.png)[![Phase 2 Badge](media/GNOME-CEC-p2-small.png)](media/GNOME-CEC-p2.png)
* The National Science Foundation (DUE-2013069) - Collaborative Research: Broadening Participation in Computing through Authentic, Collaborative Engagement with Computing for the Greater Good.
* [Zulip](https://zulip.com) provides sponsored hosting for [FarmData2 community discussions](https://farmdata2.zulipchat.com/#narrow/stream/270883-general).
--
2.36.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
git stash
git switch main
git switch -c add-conflicts-for-practicing-merges-with-conflicts
git am "${SCRIPT_DIR}"/*.patch
git switch main
git stash pop
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From 8d03822daf8d30fc192b4543d7992ee0b0ea099e Mon Sep 17 00:00:00 2001
From: Grant Braught <[email protected]>
Date: Fri, 12 Nov 2021 08:37:19 -0500
Subject: [PATCH] Changes that conflict with Round2 Issues.

Each of the 190-Round2 issues in the issue tracker add links to the README.md file. This commit, when merged into main will introduce changes that conflict with all of the changes requested by those issues. It should be merged after students synch with main and as or just after they submit their PR's for the 190-Round2 issues.
---
README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 9d26f8e..efb70b6 100644
--- a/README.md
+++ b/README.md
@@ -22,18 +22,18 @@ If you are unfamiliar with [Zulip](https://zulip.com/) it is a group chat applic

### History ###

-FarmData2 is both a _second_ edition of it predecessor, FarmData, and the integration of _two_ related projects FarmData and AnimalData. These projects were conceived and built by Tim Wahls, Matt Steiman and many students to support operation of the Dickinson College Farm. The FarmData2 project was initiated as a part of curricular redesign in the Computer Science Department at Dickinson College. It is now an active part of several courses in the curriculum. It provides students in these courses with early and sustained opportunities to learn and practice modern software development within the context of an open source software community.
+FarmData2 is both a _second_ edition of it predecessor, FarmData, and the integration of _two_ related projects FarmData and AnimalData. These projects were conceived and built by Tim Wahls, Matt Steiman and many students to support operation of the [Dickinson College Farm](https://not.the.right.link1). The FarmData2 project was initiated as a part of curricular redesign in the Computer Science Department at Dickinson College. It is now an active part of several courses in the curriculum. It provides students in these courses with early and sustained opportunities to learn and practice modern software development within the context of an open source software community.

### Acknowledgements ###

-FarmData2 is powered by the farmOS open source project.
+FarmData2 is powered by the [farmOS](https://not.the.right.link2) open source project.

Support and assistance with FarmData2 development has been received from [The Non-Profit FOSS Institute](https://npfi.org/).

The development of FarmData2 has received partial support from:
-* The GNOME Community Engagement Challenge:
+* The [GNOME Community Engagement Challenge](https://not.the.right.link3):
* [![Phase 1 Badge](media/GNOME-CEC-p1-small.png)](media/GNOME-CEC-p1.png)[![Phase 2 Badge](media/GNOME-CEC-p2-small.png)](media/GNOME-CEC-p2.png)
-* The National Science Foundation (DUE-2013069) - Collaborative Research: Broadening Participation in Computing through Authentic, Collaborative Engagement with Computing for the Greater Good.
+* The National Science Foundation ([DUE-2013069](https://not.the.right.link4)) - Collaborative Research: Broadening Participation in Computing through Authentic, Collaborative Engagement with Computing for the Greater Good.
* [Zulip](https://zulip.com) provides sponsored hosting for [FarmData2 community discussions](https://farmdata2.zulipchat.com/#narrow/stream/270883-general).

---
--
2.36.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
git stash
git switch main
git switch -c add-round-two-conflicts
git am "${SCRIPT_DIR}"/*.patch
git switch main
git stash pop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Allow anyone to self-assign an issue"

on: [issue_comment]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: bhermann/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

## This script is called after the new instance has been created and
## initialiazed. It runs in the local clone of the instance.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";

set -e

project_dir="$(
while [[ ! -d .git ]] ; do
cd ..
done
pwd
)"
workflows_dir="${project_dir}/.github/workflows"
mkdir -p "$workflows_dir"
cp "$SCRIPT_DIR/allow-anyone-to-self-assign-an-issue.yaml" "$workflows_dir"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

## This script is called once after the instance is cloned by a KitClient.
## It runs in the clone of the instance in a KitClient.

git config --local branch.main.mergeoptions "--no-ff"
85 changes: 85 additions & 0 deletions .kit/features/5-detect-upstream-clone/install-into-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash

## This script is called once after the instance is cloned by a KitClient.
## It runs in the clone of the instance in a KitClient.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";

# shellcheck disable=SC1091
source "${SCRIPT_DIR}/upstream-location.sh"

function main() {
detect-upstream-clone
}

function detect-upstream-clone() {
upstream="$(load-upstream-location)"
origin="$(get-origin-location)"

# Case insensitive check.
upstream="$(echo "$upstream" | tr '[:upper:]' '[:lower:]')"
origin="$(echo "$origin" | tr '[:upper:]' '[:lower:]')"
if [[ "$origin" == "$upstream" ]] ; then
display-error-message
fi
}

function get-origin-location() {
convert-url-to-org-repo "$(get-origin-url)"
}

function get-origin-url() {
git remote get-url origin
}

function convert-url-to-org-repo() {
url="$1"
if [[ "$url" =~ ^git.* ]] ; then
convert-git-url-to-org-repo "$url"
else
convert-http-url-to-org-repo "$url"
fi
}

function convert-git-url-to-org-repo() {
url="$1"
url="$(remove-prefix-to-first-colon "$url")"
url="$(remove-suffix-dot-git "$url")"
echo "$url"
}

function convert-http-url-to-org-repo() {
url="$1"
url="$(remove-prefix-http "$url")"
url="$(remove-suffix-dot-git "$url")"
echo "$url"
}

function remove-prefix-to-first-colon() {
echo "${1#*:}"
}

function remove-suffix-dot-git() {
echo "${1%.git}"
}

function remove-prefix-http() {
local url="${1}"
url="${url#*//}"
echo "${url#*/}"
}

function display-error-message() {
echo "*********************************************************************"
printf "\xF0\x9F\x98\xBA\xF0\x9F\x92\xBB Meow, Kit-tty here!\n"
echo
echo "Oops, I think you have cloned the upstream repository instead of your"
echo "fork. But don't worry. You can fix it!"
echo
echo "1. Delete your local repository."
echo "2. Navigate to your fork on GitHub and copy its clone URL."
echo "3. Clone your fork using its clone URL."
echo "*********************************************************************"
}

main
50 changes: 50 additions & 0 deletions .kit/features/5-detect-upstream-clone/install-into-instance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

## This script is called after the new instance has been created and
## initialiazed. It runs in the local clone of the instance.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";

source "${SCRIPT_DIR}/upstream-location.sh"

function main() {
save-upstream-location "$(get-upstream-location)"
}

function get-upstream-location() {
get-origin-location
}

function get-origin-location() {
convert-url-to-org-repo "$(get-origin-url)"
}

function get-origin-url() {
git remote get-url origin
}

function convert-url-to-org-repo() {
local n="$1"
if [[ "$n" =~ ^git.* ]] ; then
# remove [email protected] prefix
n="${n#git@github.com:}"
else
# remove https://github.com/ prefix
n="${n#https://*github.com/}"
fi
# remove .git suffix
n="${n%.git}"
echo "$n"
}

function get-upstream-location-file() {
echo "$SCRIPT_DIR/upstream-location.txt"
}

function commit-and-push-upstream-location() {
git add "$(get-upstream-location-file)"
git commit -m "build(kit): add upstream location"
git push
}

main
11 changes: 11 additions & 0 deletions .kit/features/5-detect-upstream-clone/upstream-location.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";

save-upstream-location() {
echo "${1}" > "${SCRIPT_DIR}/upstream-location.txt"
}

load-upstream-location() {
cat "${SCRIPT_DIR}/upstream-location.txt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dickinson-comp190/GitKit-FarmData2
10 changes: 10 additions & 0 deletions .kit/features/5-prevent-commit-to-main/install-into-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

## This script is called once after the instance is cloned by a KitClient.
## It runs in the clone of the instance in a KitClient.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
PROJECT_DIR="$(git rev-parse --show-toplevel)"

cp "$SCRIPT_DIR/prevent-commit-to-main.sh" "$PROJECT_DIR/.git/hooks/pre-commit"
chmod +x "$PROJECT_DIR/.git/hooks/pre-commit"
28 changes: 28 additions & 0 deletions .kit/features/5-prevent-commit-to-main/prevent-commit-to-main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Hook to verify that commits are not made to the main branch accidentally
# Based on https://gist.github.com/ilyakatz/4625224#file-pre-commit-master-no-no

if [[ $(git symbolic-ref HEAD) == "refs/heads/main" ]]
then
echo "**********************************************************************"
printf "\xF0\x9F\x98\xBA\xF0\x9F\x92\xBB Meow, Kit-tty here!\n"
echo "You should not be committing to the main branch."
echo "You should be committing to a feature branch."
echo
echo "Here's how:"
echo
echo "1. Create a feature branch, if you don't already have one."
echo
echo " git branch <branchname>"
echo
echo "2. Switch to that branch."
echo
echo " git switch <branchname>"
echo
echo "3. Retry your commit."
echo
echo "That's it! Have fun! Meow!"
echo "**********************************************************************"
exit 1
fi
10 changes: 10 additions & 0 deletions .kit/features/5-prevent-merge-to-main/install-into-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

## This script is called once after the instance is cloned by a KitClient.
## It runs in the clone of the instance in a KitClient.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
PROJECT_DIR="$(git rev-parse --show-toplevel)"

cp "$SCRIPT_DIR/prevent-merge-to-main.sh" "$PROJECT_DIR/.git/hooks/pre-merge-commit"
chmod +x "$PROJECT_DIR/.git/hooks/pre-merge-commit"
21 changes: 21 additions & 0 deletions .kit/features/5-prevent-merge-to-main/prevent-merge-to-main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Hook to verify that commits are not made to the main branch accidentally
# Based on https://gist.github.com/ilyakatz/4625224#file-pre-commit-master-no-no

if [[ $(git symbolic-ref HEAD) == "refs/heads/main" ]]
then
echo "**********************************************************************"
printf "\xF0\x9F\x98\xBA\xF0\x9F\x92\xBB Meow, Kit-tty here!\n"
echo "You should not be merging to the main branch."
echo "You should only be merging in a GitHub pull request."
echo "The working tree is still in a merging state."
echo
echo "Before continuing, run the command:"
echo
echo " git reset --merge"
echo
echo "Ignore messages after this line"
echo "**********************************************************************"
exit 1
fi
10 changes: 10 additions & 0 deletions .kit/features/5-prevent-rebase/install-into-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

## This script is called once after the instance is cloned by a KitClient.
## It runs in the clone of the instance in a KitClient.

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
PROJECT_DIR="$(git rev-parse --show-toplevel)"

cp "$SCRIPT_DIR/prevent-rebase.sh" "$PROJECT_DIR/.git/hooks/pre-rebase"
chmod +x "$PROJECT_DIR/.git/hooks/pre-rebase"
Loading

0 comments on commit 9ecaf33

Please sign in to comment.