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

Updated installation instructions and refactored the exercise creation mecanism. #53

Open
wants to merge 87 commits into
base: verifications
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
8fbeef9
Exercise base
fracz Mar 22, 2015
042b95b
Git exercises - introduction
fracz Mar 20, 2015
22f1fd9
Remove unnecessary info from master
fracz Feb 26, 2016
a13b377
Sed-out remote: prefix from git response
fracz Feb 27, 2016
2dc0c83
New exercises alias
fracz Feb 27, 2016
1bc6424
Enhance git verify alias
fracz Feb 28, 2016
23aeacd
Enhance git start command
fracz Feb 28, 2016
a1f208b
Allow to git verify in detached HEAD
fracz Feb 29, 2016
257aa33
More info in detached HEAD
fracz Feb 29, 2016
83880e4
More info on git start when ./start.sh fails
fracz Mar 6, 2016
439b422
Add git start next command
fracz Mar 14, 2016
a3ed55d
Clear instruction to start with git verify
fracz Mar 20, 2019
4252cf9
Enhance git verify alias (do not fail if on not-tracked branch)
fracz Mar 5, 2020
47d5549
Fix git start next command (always check from master)
fracz Mar 5, 2020
a798646
Making it run on local machine
marijnl Sep 3, 2020
a36bd87
start command with custom domain
marijnl Sep 3, 2020
c1e4271
forgot to change env var
marijnl Sep 3, 2020
7cf21c5
find replace domain name to match .env file
marijnl Sep 3, 2020
650fd63
Make configure.sh work with i18n git by requiring POSIX locale.
yeputons Nov 17, 2019
6bd8f8f
Add --local to git config commands in configure.sh ref #28
fracz Apr 21, 2021
2c87595
Traduction française automatique
plafrance Aug 24, 2022
7a191f7
Traduction française automatique
plafrance Aug 24, 2022
02d4eb2
Traduction française automatique
plafrance Aug 24, 2022
75b1d4f
Traduction française automatique
plafrance Aug 24, 2022
bbee630
Traduction française automatique
plafrance Aug 24, 2022
55fc3ae
Traduction française automatique
plafrance Aug 24, 2022
b8ced30
Traduction française automatique
plafrance Aug 24, 2022
a6b23b8
Traduction française automatique
plafrance Aug 24, 2022
c977c28
Traduction française automatique
plafrance Aug 24, 2022
a5b4b35
Traduction française automatique
plafrance Aug 24, 2022
50ebfd9
Traduction française automatique
plafrance Aug 24, 2022
6e04295
Traduction française automatique
plafrance Aug 24, 2022
a1277e8
Traduction française automatique
plafrance Aug 24, 2022
0eed626
Traduction française automatique
plafrance Aug 24, 2022
ec13c4a
Traduction française automatique
plafrance Aug 24, 2022
ee582f4
Traduction française automatique
plafrance Aug 24, 2022
3ecfc3a
Traduction française automatique
plafrance Aug 24, 2022
8337431
Traduction française automatique
plafrance Aug 24, 2022
a73e4b2
Traduction française automatique
plafrance Aug 24, 2022
ac2966c
Traduction française automatique
plafrance Aug 24, 2022
1eecea3
Traduction française automatique
plafrance Aug 24, 2022
eb0ec62
Traduction française automatique
plafrance Aug 24, 2022
cad80f5
Traduction française automatique
plafrance Aug 24, 2022
8778d0b
Traduction française automatique
plafrance Aug 24, 2022
fb630bb
Merge branch 'verifications' of https://github.com/marijnl/git-exerci…
plafrance Dec 27, 2022
9ab6f83
Merge from marijnl
plafrance Dec 27, 2022
f43f071
Fix detecting if any progress was made in the exercise
fracz Apr 21, 2021
caa93ac
Renamed env-file
plafrance Dec 28, 2022
0a1626f
Typo
plafrance Dec 28, 2022
286b010
Updated building mecanism
plafrance Dec 28, 2022
8b53bd8
Déplacé les hints et vérifications dans leur propre branche
plafrance Dec 28, 2022
30a4ca4
Renamed branch verifications to website
plafrance Dec 28, 2022
d4afcd7
Corrected the worktree path
plafrance Dec 28, 2022
0890eac
Allowed display on small screens
plafrance Dec 29, 2022
f7823be
Making it run on local machine
marijnl Sep 3, 2020
e4950b3
start command with custom domain
marijnl Sep 3, 2020
8ea67e7
forgot to change env var
marijnl Sep 3, 2020
66571dd
find replace domain name to match .env file
marijnl Sep 3, 2020
a6aeff9
Merge from marijnl
plafrance Dec 27, 2022
2eca9c2
Renamed env-file
plafrance Dec 28, 2022
863b318
Typo
plafrance Dec 28, 2022
4b4ef1a
Updated building mecanism
plafrance Dec 28, 2022
c302af7
Déplacé les hints et vérifications dans leur propre branche
plafrance Dec 28, 2022
3b24284
Renamed branch verifications to website
plafrance Dec 28, 2022
e37f0bb
Corrected the worktree path
plafrance Dec 28, 2022
f44a3d3
Allowed display on small screens
plafrance Dec 29, 2022
4a07950
Test avec un premier exercice dans la branche principale
plafrance Dec 29, 2022
74994d3
Replaced master with main
plafrance Dec 31, 2022
5ed43f4
Allowed for exercises to be fetched from arbitrary repo
plafrance Dec 31, 2022
42c8076
Corrigé les noms de fichier
plafrance Dec 31, 2022
5855acf
Déplacé getSolution
plafrance Dec 31, 2022
08516ef
Merge branch 'website' of git.dti.crosemont.quebec:plafrance/git-exer…
plafrance Dec 31, 2022
c3cb6aa
Corrigé nom de paramètre
plafrance Dec 31, 2022
2f733a7
Assure la copie des fichiers cachés
plafrance Dec 31, 2022
1a9f04f
Amélioré la config du dépôt
plafrance Jan 4, 2023
8347ada
Amélioré la config du dépôt
plafrance Jan 4, 2023
fe9780b
Ajouté la possibilité d'obtenir les changements entre deux commits
plafrance Jan 10, 2023
a462ff0
Merge branch 'website' of git.dti.crosemont.quebec:plafrance/git-exer…
plafrance Jan 10, 2023
9fb109b
Changed the way ownership is given to www-data
plafrance Feb 24, 2023
423c945
Merge branch 'website'
plafrance Feb 24, 2023
e9c0749
Revert "Traduction française automatique"
plafrance Feb 24, 2023
efc25ce
Added exercices
plafrance Feb 24, 2023
23f7b0e
Added 10 new exercises
plafrance Feb 24, 2023
5d7f7c8
Adding previously ignored dot-files
plafrance Mar 23, 2023
09aa41f
Various fixes to the building process
plafrance Mar 23, 2023
677caac
Added installation instructions
plafrance Mar 23, 2023
43de37c
Improved or fixed some solutions
plafrance Mar 24, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var/
.*
*~
27 changes: 27 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
1. Clone the repo

git clone https://github.com/fracz/git-exercises.git
cd git-exercises

2. Adjust the environment variables

cd docker
cp env.example .env

Change the values of those variables according to your domain specifics :

DOMAIN_NAME=<Your domain name> # used in the cloning URL
SITE_ADMIN_NAME=<Your admin name> # used as the committer name for given commits
SITE_ADMIN_EMAIL=<Your admin email> # used as the committer email for given commits

Change the value of this variable if you wish to use a different repo as a source of exercises :

GIT_REPO=<URL to a repo of questions>

3. Run with docker-compose

docker-compose up -d

4. The web app should be available at https://$DOMAIN_NAME/

5. The exercise repo should be available at git://$DOMAIN_NAME/git/exercises.git
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,76 @@
This repository contains the source code of the [git-exercises](https://gitexercises.fracz.com/) platform for practising git.

![git-exercises](frontend/public/images/intro.gif)

## Overview

This project consists of two docker images: mysql and an apache server.

## Setup

*Windows 10*:
```
Docker desktop community 2.3.0.3
- docker-compose version 1.25.5, build 8a1c60f6
- Docker version 19.03.8, build afacb8b
MySQL Workbench 8.0
```

*Ubuntu 18.04.5*:
```
docker-compose version 1.17.1, build unknown
Docker version 19.03.6, build 369ce74a3c
mysql-client-core-5.7
```

## Configuration

The only file you need to update is `docker/.env`

## How to build

In directory `/docker` run
```
docker-compose build
```

Make sure the default branch of your repo is `verifications`

## How to run

In directory `/docker` run
```
docker-compose run
```

## Database schema initialization

First time you need to run `backend/schema/gitexercises.sql`

To execute these instructions do

```bash
# login to mysql running in docker container
mysql -h localhost -P 3306 --protocol=tcp -u root
# in mysql shell
CREATE DATABASE <DB_NAME as defined in docker/.env>;
USE <DB_NAME as defined in docker/.env>;
# run the sql file
source 'backend/schema/gitexercises.sql'

```

## Start exercising

Assuming you run on localhost, this is how you start with exercise 1

```bash
git clone http://localhost/git/exercises.git git-exercises
cd git-exercises
./configure.sh
git start
```

## Adding new exercises

See [CONTRIBUTING.md](CONTRIBUTING.md)
1 change: 0 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
composer.phar
config.php
*.log
*.bak
2 changes: 1 addition & 1 deletion backend/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "git-exercises",
"name": "fracz/git-exercises",
"require": {
"php": ">=5.5",
"slim/slim": "2.6.2",
Expand Down
118 changes: 0 additions & 118 deletions backend/composer.lock

This file was deleted.

10 changes: 10 additions & 0 deletions backend/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/*
* Copy this file into config.php and adjust values below to match your environment.
*/

define('DB_HOST', getenv('DB_HOST'));
define('DB_NAME', getenv('DB_NAME'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASSWORD', getenv('DB_PASSWORD'));
define('DOMAIN_NAME', getenv('DOMAIN_NAME'));
9 changes: 0 additions & 9 deletions backend/config.sample.php

This file was deleted.

2 changes: 1 addition & 1 deletion backend/controllers/CommitterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getAction($id)
$result['passedExercises'] = $this->getApp()->committerService->getPassedExercises($id);
$result['nextExercise'] = $this->getApp()->committerService->suggestNextExercise($result['passedExercises']);
} else {
$result['nextExercise'] = 'master';
$result['nextExercise'] = 'main';
$result['passedExercises'] = [];
}
return $result;
Expand Down
8 changes: 0 additions & 8 deletions backend/hook/AbstractVerification.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ public function verify()
$this->doVerify();
}

public function getSolution()
{
$solutionFile = __DIR__ . '/hints/' . get_class($this) . '-solution.txt';
if (file_exists($solutionFile)) {
return file_get_contents($solutionFile);
}
}

protected abstract function doVerify();

protected function ensure($condition, $errorMessage, array $formatVars = [])
Expand Down
2 changes: 0 additions & 2 deletions backend/hook/hints/CommitOneFile-solution.txt

This file was deleted.

3 changes: 0 additions & 3 deletions backend/hook/hints/CommitOneFileStaged-hint.md

This file was deleted.

1 change: 0 additions & 1 deletion backend/hook/hints/Executable-hint.md

This file was deleted.

3 changes: 0 additions & 3 deletions backend/hook/hints/FixTypo-solution.txt

This file was deleted.

4 changes: 0 additions & 4 deletions backend/hook/hints/MergeConflict-solution.txt

This file was deleted.

9 changes: 6 additions & 3 deletions backend/hook/hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
ini_set("error_log", __DIR__ . "/../data/logs/hook-error.log");

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../config.php';

use GitExercises\hook\utils\ConsoleUtils;
use GitExercises\hook\utils\GitUtils;
use GitExercises\services\ExerciseUtils;
use GitExercises\services\CommitterService;
use GitExercises\services\GamificationService;
use GitExercises\services\ShortIdService;

define('DOMAIN', 'https://gitexercises.fracz.com');
define('DOMAIN', 'http://' . DOMAIN_NAME);

$branch = $argv[1];
$oldRev = $argv[2];
Expand All @@ -35,8 +37,9 @@
$shortCommiterId = (new ShortIdService())->getShort($committerId);
$gamificationService = new GamificationService($committerId);

$possibleCommand = ucfirst(AbstractVerification::dashToCamelCase($exercise));
$possibleCommand = ucfirst($exercise);
$command = 'GitExercises\\hook\\commands\\' . $possibleCommand . 'Command';

if (class_exists($command)) {
(new $command())->execute($committerId);
} else {
Expand All @@ -55,7 +58,7 @@
try {
$verifier->verify();
echo ConsoleUtils::green('PASSED') . PHP_EOL;
$solution = $verifier->getSolution();
$solution = ExerciseUtils::getExerciseSolution($exercise);
if ($solution) {
echo PHP_EOL . ConsoleUtils::pink('The easiest solution:') . PHP_EOL . trim($solution) . PHP_EOL . PHP_EOL;
}
Expand Down
6 changes: 3 additions & 3 deletions backend/hook/utils/GitUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public static function getCommitDate($commitId)
* @param $commitId
* @return array indexed by filenames, values are operations (M, A, D)
*/
public static function getChangedFiles($commitId)
public static function getChangedFiles($commitId, $secondCommitId="")
{
exec("git diff-tree --no-commit-id --name-status -r $commitId", $changes);
exec("git diff-tree --no-commit-id --name-status -r $commitId $secondCommitId", $changes);
$changedFiles = [];
foreach ($changes as $change) {
$data = explode("\t", $change);
Expand Down Expand Up @@ -83,7 +83,7 @@ public static function checkIgnore($commitId, $filename)
{
exec("git checkout -q $commitId");
exec("git check-ignore -v $filename", $result, $status);
exec("git checkout -q master");
exec("git checkout -q main");
if ($status) {
return false;
}
Expand Down
15 changes: 0 additions & 15 deletions backend/hook/verifications/CommitOneFile.php

This file was deleted.

Binary file removed backend/schema/gitexercises.mwb
Binary file not shown.
4 changes: 2 additions & 2 deletions backend/scripts/exercise-tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
if (!is_dir($repo)) {
system('cd ' . __DIR__ . ' && git clone ' . REPO_URL . ' ' . LOCAL_DIR_NAME);
run('git checkout verifications');
run('git branch -D master');
run('git branch -D main');
run('git remote rm origin');
run('git remote add origin ' . VERIFICATION_URL);
run('git fetch origin');
run('git checkout master');
run('git checkout main');
run('configure.sh');
}

Expand Down
Loading