Skip to content

Commit

Permalink
added my-documents + verbose logs on Git::pullIfNoChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
fchastanet committed Jan 14, 2024
1 parent 2f52d3a commit fd5507f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
20 changes: 12 additions & 8 deletions bin/doc
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,12 @@ Git::cloneOrPullIfNoChanges() {
shift || true

if [[ -d "${dir}/.git" ]]; then
if Git::pullIfNoChanges "${dir}"; then
# shellcheck disable=SC2086
if [[ "$(type -t ${pullCallback})" = "function" ]]; then
${pullCallback} "${dir}"
fi
if ! Git::pullIfNoChanges "${dir}"; then
return 1
fi
# shellcheck disable=SC2086
if [[ "$(type -t ${pullCallback})" = "function" ]]; then
${pullCallback} "${dir}"
fi
else
Log::displayInfo "cloning ${repo} ..."
Expand Down Expand Up @@ -1148,11 +1149,14 @@ Git::pullIfNoChanges() {
return 3
fi
(
cd "${dir}" || exit 3
git update-index --refresh &>/dev/null || exit 4
cd "${dir}" || return 3
if ! git update-index --refresh &>/dev/null; then
Log::displayWarning "Impossible to update git index of '${dir}' - check if you have modified file"
return 4
fi
if ! git diff-index --quiet HEAD --; then
Log::displayWarning "Pulling git repository '${dir}' avoided as changes detected"
exit 2
return 2
fi
Log::displayInfo "Pull git repository '${dir}' as no changes detected"
git pull --progress
Expand Down
3 changes: 2 additions & 1 deletion pages/_navbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

[Bash Tools Framework](/) |
[Bash Tools](https://fchastanet.github.io/bash-tools/) |
[Bash Dev Env](https://fchastanet.github.io/bash-dev-env/)
[Bash Dev Env](https://fchastanet.github.io/bash-dev-env/) |
[My documents](https://fchastanet.github.io/my-documents/)
12 changes: 12 additions & 0 deletions pages/images/external-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
{
display: none !important;
}
a:visited {
color: inherit;
}
</style>
</head>
<body>
Expand Down
11 changes: 6 additions & 5 deletions src/Git/cloneOrPullIfNoChanges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ Git::cloneOrPullIfNoChanges() {
shift || true

if [[ -d "${dir}/.git" ]]; then
if Git::pullIfNoChanges "${dir}"; then
# shellcheck disable=SC2086
if [[ "$(type -t ${pullCallback})" = "function" ]]; then
${pullCallback} "${dir}"
fi
if ! Git::pullIfNoChanges "${dir}"; then
return 1
fi
# shellcheck disable=SC2086
if [[ "$(type -t ${pullCallback})" = "function" ]]; then
${pullCallback} "${dir}"
fi
else
Log::displayInfo "cloning ${repo} ..."
Expand Down
9 changes: 6 additions & 3 deletions src/Git/pullIfNoChanges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ Git::pullIfNoChanges() {
return 3
fi
(
cd "${dir}" || exit 3
git update-index --refresh &>/dev/null || exit 4
cd "${dir}" || return 3
if ! git update-index --refresh &>/dev/null; then
Log::displayWarning "Impossible to update git index of '${dir}' - check if you have modified file"
return 4
fi
if ! git diff-index --quiet HEAD --; then
Log::displayWarning "Pulling git repository '${dir}' avoided as changes detected"
exit 2
return 2
fi
Log::displayInfo "Pull git repository '${dir}' as no changes detected"
git pull --progress
Expand Down

0 comments on commit fd5507f

Please sign in to comment.