[pitivi/1.0] flatpak: Fix pre-commit hook
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] flatpak: Fix pre-commit hook
- Date: Wed, 7 Feb 2018 00:09:42 +0000 (UTC)
commit 776ef2065acb26ac9c0c0dc9e6b75ab3abd2c61f
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Jan 19 02:02:31 2018 +0100
flatpak: Fix pre-commit hook
We want to use both pre-commit.com and our own `pre-commit.hook`. Since
the hooks are installed only when setting up the dev env, we can assume
there is one and error out in the pre-commit.hook. Also, we can call
pre-commit.com directly from there, as that's what pre-commit.com's
wrapper is doing.
Differential Revision: https://phabricator.freedesktop.org/D1945
bin/pitivi-env | 11 ++++++-----
build/flatpak/pitivi-flatpak | 19 +++++++++++--------
pre-commit.hook | 36 ++++++++++++++++++------------------
3 files changed, 35 insertions(+), 31 deletions(-)
---
diff --git a/bin/pitivi-env b/bin/pitivi-env
index 604d5bd..3034b11 100755
--- a/bin/pitivi-env
+++ b/bin/pitivi-env
@@ -12,7 +12,7 @@ SCRIPT=${BASH_SOURCE[0]:-$0}
&& exit 1
SCRIPT_DIR=$(dirname $(realpath $SCRIPT))
-PITIVI_REPO_DIR=$(realpath $SCRIPT_DIR/..)
+export PITIVI_REPO_DIR=$(realpath $SCRIPT_DIR/..)
export FLATPAK_ENVPATH=$(realpath $PITIVI_REPO_DIR/..)
export CURRENT_GST=$FLATPAK_ENVPATH
export PATH="$FLATPAK_ENVPATH/bin/:$PATH"
@@ -22,11 +22,12 @@ alias ptvenv="$PITIVI_REPO_DIR/build/flatpak/pitivi-flatpak -d"
echo "-> Setting up the prefix for the sandbox..."
# This builds the local flatpak repo if it is not yet built.
-ptvenv echo Prefix ready
+ptvenv echo Setting up the sandbox prefix...
if [ "$?" = "0" ];
then
- # Set up environment variables and aliases so configuring, building, etc.
- # takes place in the sandbox.
+ echo Sandbox ready.
+
+ echo Setting up aliases etc. so configuring, building takes place in the sandbox...
# Meson sets up the build directory where ninja works.
# Consider using `setup` instead of `meson`, see below.
@@ -60,7 +61,7 @@ then
# such as git-phab, pre-commit, etc.
source $PITIVI_REPO_DIR/build/flatpak/pyvenv/bin/activate
- # Install the pre-commit framework as a git hook, for doing clean commits.
+ # Install our pre-commit git hook, for doing clean commits.
rm -f .git/hooks/pre-commit
ln -s ../../pre-commit.hook .git/hooks/pre-commit
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index 8899bdd..9b52014 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
# pylint: disable=missing-docstring,invalid-name
-
import argparse
import configparser
import json
@@ -28,7 +27,6 @@ import subprocess
import sys
import tempfile
import venv
-
from urllib.parse import urlparse
from urllib.request import urlretrieve
@@ -310,7 +308,7 @@ class FlatpakPackage(FlatpakObject):
def install(self):
if not self.repo:
- return False
+ return
self.flatpak("install", self.repo.name, self.name,
self.branch, show_output=True,
@@ -318,7 +316,8 @@ class FlatpakPackage(FlatpakObject):
def update(self):
if not self.is_installed():
- return self.install()
+ self.install()
+ return
self.flatpak("update", self.name, self.branch, show_output=True,
comment="Updating %s" % self.name)
@@ -504,7 +503,8 @@ class PitiviFlatpak: # pylint: disable=too-many-instance-attributes
def setup_sandbox(self):
"""Creates the sandbox."""
- if not os.path.exists(self.prefix) or self.update:
+ fresh_install = not os.path.exists(self.prefix)
+ if fresh_install or self.update:
self.install_all()
Console.message("Building Pitivi %s and dependencies in %s",
self.branch, self.prefix)
@@ -545,16 +545,18 @@ class PitiviFlatpak: # pylint: disable=too-many-instance-attributes
venv_path = os.path.join(self.scriptdir, "pyvenv")
activate_script = os.path.join(venv_path, "bin", "activate")
+ pip_modules = "git-phab pre-commit git-pylint-commit-hook git_pep8_commit_hook"
if not os.path.isdir(venv_path):
- print("Installing development tools in a virtual env.")
+ print("Setting up a Python virtual env: %s" % venv_path)
venv.create(venv_path, with_pip=True)
+ print("Installing development tools in a Python virtual env: %s" % venv_path)
subprocess.check_call(
- ". %s && pip install pre-commit git-phab" % activate_script,
+ ". %s && pip install %s" % (activate_script, pip_modules),
shell=True)
if self.update:
subprocess.check_call(
- ". %s && pip install -U pre-commit git-phab" % activate_script,
+ ". %s && pip install -U %s" % (activate_script, pip_modules),
shell=True)
if not self.check and not self.update:
@@ -564,6 +566,7 @@ class PitiviFlatpak: # pylint: disable=too-many-instance-attributes
flatpak_command = ["flatpak", "build", "--socket=x11",
"--socket=session-bus", "--socket=pulseaudio",
"--share=network", "--env=PITIVI_DEVELOPMENT=1",
+ "--env=PYTHONUSERBASE=/app/",
"--env=CC=ccache gcc",
"--env=CXX=ccache g++", "--device=dri"]
diff --git a/pre-commit.hook b/pre-commit.hook
index 49d2d64..cdd8928 100755
--- a/pre-commit.hook
+++ b/pre-commit.hook
@@ -1,6 +1,12 @@
#!/usr/bin/env bash
-RCFILE=$(git rev-parse --show-toplevel)/docs/pylint.rc
+if [ -z "${PITIVI_REPO_DIR}" ]; then
+ echo "ERROR: You're not in the Pitivi development environment. Run `source bin/pitivi-env` to enter it.
See http://developer.pitivi.org/HACKING.html for details."
+ exit 1
+fi
+
+TOPLEVEL=$(git rev-parse --show-toplevel)
+RCFILE=$TOPLEVEL/docs/pylint.rc
IGNORED_FILES="
bin/pitivi.in
@@ -71,23 +77,17 @@ win32/configure.py
win32/pitivi
"
-git-pylint-commit-hook --help |grep ignore > /dev/null 2>&1
-
-if [ $? -ne 0 ]; then
- echo "Your git-pylint-commit-hook version can't ignore files that have not been fixed yet"
- echo "Use instead our fork:"
- echo " $ pip install git+git://github.com/thiblahute/git-pylint-commit-hook.git"
- echo ""
-elif [ -z $PYLINT ]; then
- IGNORE_ARGS=''
- for f in $IGNORED_FILES; do
+IGNORE_ARGS=""
+for f in $IGNORED_FILES; do
IGNORE_ARGS="$IGNORE_ARGS --ignore=$f"
- done
- echo "Pylint ignoring files:$IGNORED_FILES" | tr "\n" " "
- echo
-fi
+done
+echo "Pylint ignoring files:$IGNORED_FILES" | tr "\n" " "
+echo
+
+export PYTHONPATH=$TOPLEVEL/pitivi/coptimizations/.libs:$PYTHONPATH
+
+git-pylint-commit-hook --pylint="$TOPLEVEL/build/flatpak/pitivi-flatpak" --pylint-params="-d pylint"
--pylintrc=$RCFILE $IGNORE_ARGS --limit=10.0 --suppress-report || exit 1
-export PYTHONPATH=$(git rev-parse --show-toplevel)/pitivi/coptimizations/.libs:$PYTHONPATH
+git_pep8_commit_hook --pep8-params="--repeat --ignore=E501,E128" || exit 1
-git-pylint-commit-hook --pylintrc=$RCFILE $IGNORE_ARGS --limit=10.0 --suppress-report &&\
- git_pep8_commit_hook --pep8-params="--repeat --ignore=E501,E128"
+pre-commit run --config .pre-commit-config.yaml || exit 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]