From 1bbe9cc243f5d1034067880b3f42ddbfcc6651c9 Mon Sep 17 00:00:00 2001 From: Myles Byrne Date: Thu, 4 Sep 2014 18:39:30 -0700 Subject: [PATCH] test and cleanup user metadata --- README.md | 30 +++++++++++++++++------------- metadata/realtime/user.sh | 26 +++++++------------------- test/.gitconfig | 6 ++++++ test/user-metadata | 12 ++++++++++++ 4 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 test/.gitconfig create mode 100755 test/user-metadata diff --git a/README.md b/README.md index c3bb730..0f422b8 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,19 @@ the system has 2 parts: > this system is invoked every time a student runs the ruby interpreter at the console ```text -+------------+ -| ruby-shim | -+---+---+----+----> STDOUT \ - | | |--> typical student experience - | (T)+-------> STDERR / - | | - | +----------------------> /tmp/ruby-runs/stderr.1234 - | - +---> create-metadata.sh - - /realtime \ ++------------+ +| ruby-shim | ++---+---+----+----> STDOUT \ + | | |--> typical student experience + | (T)+-------> STDERR / + | | + | +----------------------> /tmp/ruby-runs/stderr.1234 + | + +---> create-metadata.sh + + /realtime \ - git.sh |--> /tmp/ruby-runs/metadata.1234 - - machine.sh / + - machine.sh / ``` notes: @@ -88,6 +88,10 @@ notes: *am i missing anyone?* +### testing + +the `test` folder has a bunch of scripts that will invoke the individual modules with dummy data. they're technically not "tests" because they don't have any assertions. use these scripts during development. + ### project history **August 20 - August 25** @@ -95,7 +99,7 @@ notes: re-write: - to address some of the major issues with the first version - to rename the project -- for me to practice writing shell scripts +- for me to practice writing shell scripts - for me to practice using git and github **July 30 - August 20** diff --git a/metadata/realtime/user.sh b/metadata/realtime/user.sh index 9e63209..3dab6f8 100644 --- a/metadata/realtime/user.sh +++ b/metadata/realtime/user.sh @@ -1,21 +1,9 @@ -# We could also capture git usernames with something like -# git config --global --get-all github.username +echo "email:" $(git config --global --get user.email) -# Grab pair names -pair_names="$(git config --global user.name)" +# exit unless the github.username field is set in the git conf +git config --global --get github.username > /dev/null || exit -# Store IFS to split string on custom character then restore IFS -oIFS=$IFS; IFS='&'; names=($pair_names); IFS=$oIFS - -# Grab pair accounts -pair_github="$(git config --global user.email | sed -e s/^.*\+// -e s/@.*$//)" -github=(${pair_github//./ }) - - -echo "pair:" -echo " user-a:" -echo " name:" "${names[0]}" -echo " github:" "${github[0]}" -echo " user-b:" -echo " name:" "${names[1]}" -echo " github:" "${github[1]}" +echo "github_usernames:" +git config --global --get-all github.username | while read github_username ; do + echo "-" $github_username +done diff --git a/test/.gitconfig b/test/.gitconfig new file mode 100644 index 0000000..4ddd444 --- /dev/null +++ b/test/.gitconfig @@ -0,0 +1,6 @@ +[user] + email = bob@example.com + +[github] + username = bob + username = jane diff --git a/test/user-metadata b/test/user-metadata new file mode 100755 index 0000000..9e0ed4c --- /dev/null +++ b/test/user-metadata @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +# ensure we're in the parent directory of this file +cd $(dirname $0)/.. + +# There's a .gitconfig file in this folder for this test so we pretend +# this folder is $HOME causing git to read that config +export HOME='./test' + +sh metadata/realtime/user.sh