aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSwift Geek <swiftgeek@gmail.com>2019-03-29 08:43:02 +0000
committerGogs <gogitservice@gmail.com>2019-03-29 08:43:02 +0000
commitfce0d8a6454e82e2c5ef1b8102ee04258331bb56 (patch)
tree33967cd745202bc31ddedcd427bcac20cd99d6dd /libs
parent8d86dd3fbd6f9f7582ae30d886bd78805e51b450 (diff)
parent89176737ad54ddbdef55e0c207ccd5dba7ade2b4 (diff)
downloadlibrebootfr-fce0d8a6454e82e2c5ef1b8102ee04258331bb56.tar.gz
librebootfr-fce0d8a6454e82e2c5ef1b8102ee04258331bb56.zip
Merge branch 'libs-git' of and_who/libreboot into master
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/git101
-rwxr-xr-xlibs/project22
2 files changed, 78 insertions, 45 deletions
diff --git a/libs/git b/libs/git
index fa4434f7..b5b2ffdb 100755
--- a/libs/git
+++ b/libs/git
@@ -41,7 +41,8 @@ git_submodule_update() {
local repository_path=$1
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git submodule update --init
)
}
@@ -51,7 +52,8 @@ git_merge() {
local revision=$2
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git merge "$revision"
)
}
@@ -62,7 +64,8 @@ git_branch_create() {
local revision=$3
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git checkout -B "$branch"
if [[ -n "$revision" ]]
@@ -77,7 +80,8 @@ git_branch_delete() {
local branch=$2
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git branch -D "$branch"
)
}
@@ -87,7 +91,8 @@ git_branch_checkout() {
local branch=$2
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git checkout "$branch" > /dev/null
)
}
@@ -97,7 +102,7 @@ git_branch_check() {
local branch=$2
(
- cd "$repository_path" >/dev/null 2>&1 || return 1
+ cd "$repository_path" 2>/dev/null || exit 1
git rev-parse --verify "$branch" >/dev/null 2>&1
)
@@ -107,7 +112,8 @@ git_fetch() {
local repository_path=$1
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git fetch origin
)
}
@@ -116,7 +122,7 @@ git_fetch_check() {
local repository_path=$1
(
- cd "$repository_path" >/dev/null 2>&1 || return 1
+ cd "$repository_path" 2>/dev/null || exit 1
git fetch --dry-run origin >/dev/null 2>&1
)
@@ -126,7 +132,8 @@ git_clean() {
local repository_path=$1
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git clean -df
)
}
@@ -136,11 +143,32 @@ git_remove() {
local path=$2
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git rm -rf "$path"
)
}
+git_diff_staged_check() {
+ local repository_path=$1
+
+ (
+ cd "$repository_path" 2>/dev/null || exit 1
+
+ git diff --staged --quiet
+ )
+}
+
+git_diff_check() {
+ local repository_path=$1
+
+ (
+ cd "$repository_path" 2>/dev/null || exit 1
+
+ git diff --quiet
+ )
+}
+
git_commit() {
local repository_path=$1
local message=$2
@@ -149,7 +177,8 @@ git_commit() {
export GIT_COMMITTER_NAME=$GIT_NAME
export GIT_COMMITTER_EMAIL=$GIT_EMAIL
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git commit --author="$GIT_NAME <$GIT_EMAIL>" -m "$message"
)
}
@@ -163,11 +192,14 @@ git_am() {
export GIT_COMMITTER_NAME=$GIT_NAME
export GIT_COMMITTER_EMAIL=$GIT_EMAIL
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git checkout "$branch" >/dev/null 2>&1
- if git_apply_check "$repository_path" "$branch" "$patch"; then
- git am "$patch" || git am --abort
+ if ! git am "$patch"; then
+ git am --abort
+
+ exit 1
fi
)
}
@@ -178,12 +210,10 @@ git_apply() {
local patch=$3
(
- cd "$repository_path"
- git checkout "$branch" >/dev/null 2>&1
+ cd "$repository_path" 2>/dev/null || exit 1
- if git_apply_check "$repository_path" "$branch" "$patch"; then
- git apply --index "$patch"
- fi
+ git checkout "$branch" >/dev/null 2>&1
+ git apply --index "$patch"
)
}
@@ -193,9 +223,9 @@ git_apply_check() {
local patch=$3
(
- cd "$repository_path"
- git checkout "$branch" >/dev/null 2>&1
+ cd "$repository_path" 2>/dev/null || exit 1
+ git checkout "$branch" >/dev/null 2>&1
git apply --check "$patch"
)
}
@@ -205,12 +235,14 @@ git_patch() {
local branch=$2
local patch=$3
+ git_apply_check "$repository_path" "$branch" "$patch" || return 1
+
case $patch in
*.patch)
git_am "$repository_path" "$branch" "$patch"
;;
*.diff)
- git_apply "$repository_path" "$branch" "$patch" &&
+ git_apply "$repository_path" "$branch" "$patch"
git_commit "$repository_path" "Applied ${patch##*/}"
;;
*)
@@ -222,7 +254,8 @@ git_revision() {
local repository_path=$1
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git rev-parse "$HEAD"
)
}
@@ -231,7 +264,8 @@ git_describe() {
local repository_path=$1
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
+
git describe --tags
)
}
@@ -240,7 +274,7 @@ git_files() {
local repository_path="$1"
(
- cd "$repository_path"
+ cd "$repository_path" 2>/dev/null || exit 1
git ls-files -z | sort -z
)
@@ -271,16 +305,16 @@ git_project_patch_recursive() {
local patches_path=$project_path/$PATCHES/$path
if ! [[ -d $project_path/$PATCHES ]]; then
- return
+ return 0
fi
+ for patch in "$patches_path"/[!.]*.@(patch|diff); do
+ git_patch "$repository_path" "$branch" "$patch" || return 1
+ done
+
if [[ $path != . ]]; then
git_project_patch_recursive "$project" "$repository" "$branch" "$(dirname "$path")"
fi
-
- for patch in "$patches_path"/[!.]*.@(patch|diff); do
- git_patch "$repository_path" "$branch" "$patch"
- done
}
git_project_clone() {
@@ -316,8 +350,8 @@ git_project_prepare() {
shift
git_project_prepare_revision "$project" "$repository" "$@"
- git_project_prepare_patch "$project" "$repository" "$@"
git_project_prepare_blobs "$project" "$repository" "$@"
+ git_project_prepare_patch "$project" "$repository" "$@"
}
git_project_prepare_blobs() {
@@ -340,7 +374,10 @@ git_project_prepare_blobs() {
git_remove "$repository_path" "$blob"
done < "$blobs_path"
- git_commit "$repository_path" "Removed blobs"
+ if ! git_diff_staged_check "$repository_path"
+ then
+ git_commit "$repository_path" "Removed blobs"
+ fi
}
git_project_prepare_patch() {
diff --git a/libs/project b/libs/project
index f2692cd6..25d6ca74 100755
--- a/libs/project
+++ b/libs/project
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
-# Copyright (C) 2018 Andrew Robbins <contact@andrewrobbins.info>
+# Copyright (C) 2018,2019 Andrew Robbins <contact@andrewrobbins.info>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -143,21 +143,17 @@ project_action() {
shift
local arguments="$*"
- (
- set +e
-
- project_action_check "$action" "$project" "$@"
+ project_action_check "$action" "$project" "$@"
- printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
+ printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
- if "$action" "$@"; then
- printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed"
- else
- printf 1>&2 '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed"
+ if (set +e; "$action" "$@"); then
+ printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed"
+ else
+ printf 1>&2 '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed"
- return 1
- fi
- )
+ return 1
+ fi
}
project_action_check() {