Skip to content

Commit

Permalink
test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
foivospro committed Oct 20, 2024
2 parents d6be0c8 + cd1755c commit 2867557
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 55 deletions.
102 changes: 51 additions & 51 deletions bin/pre-commit
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
#!/bin/sh

# Run npm run check to perform checks before committing
npm run format-check

# If npm run check fails (returns non-zero exit code), exit with error
if [ $? -ne 0 ]; then
echo "npm run check failed, aborting commit."
echo "Run 'npm run prettier-fix' to fix formatting issues."
exit 1
fi

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
#!/bin/sh

# Run npm run check to perform checks before committing
npm run format-check

# If npm run check fails (returns non-zero exit code), exit with error
if [ $? -ne 0 ]; then
echo "npm run check failed, aborting commit."
echo "Run 'npm run prettier-fix' to fix formatting issues."
exit 1
fi

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
29 changes: 25 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}

const fs = require('fs');
// Importing libraries installed with npm
const { exec } = require('child_process');
const https = require('https');
const express = require('express');
const app = express();
const path = require('path');
Expand Down Expand Up @@ -62,6 +64,25 @@ app.use((req, res, next) => {
next();
});

app.post('/github-webhook', (req, res) => {
const githubSignature = req.headers['x-hub-signature-256'];
if (req.body.ref === 'refs/heads/main') {
exec('cd /blockly && git pull origin main', (err, stdout, stderr) => {
if (err) {
console.error(`Error executing git pull: ${stderr}`);
return res.sendStatus(500);
}
console.log(`Git pull output: ${stdout}`);
return res.sendStatus(200);
});
} else {
res.sendStatus(200);
}
});

app.listen(4000, () => {
console.log('Listening for GitHub Webhooks on port 4000');
});
// Middleware to add auth token
function addAuthToken(req, res, next) {
if (req.isAuthenticated()) {
Expand Down Expand Up @@ -381,7 +402,7 @@ passport.use(
{
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: 'http://ublocks.balab.aueb.gr/auth/google/callback'
callbackURL: 'https://ublocks.balab.aueb.gr/auth/google/callback'
},
(accessToken, refreshToken, profile, done) => {
// Check if user with the given Google ID exists
Expand Down Expand Up @@ -480,6 +501,6 @@ app.get(
}
);

app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
app.listen(8443, () => {
console.log('Server is running on https://ublocks.balab.aueb.gr');
});

0 comments on commit 2867557

Please sign in to comment.