From 07cb7ef912889ab102f508f5d89ac579448e4c32 Mon Sep 17 00:00:00 2001 From: Wade Taylor Date: Fri, 30 Jun 2023 16:12:22 +1200 Subject: [PATCH] Output should indicate if a pull results in an update --- bats/branchout-projects.bats | 11 +++++++++++ branchout-project | 11 ++++++++++- output/pull/fresh-clone-reset-then-pull.txt | 1 + output/pull/fresh-clone-then-pull.txt | 2 +- output/pull/lion-update.txt | 2 +- output/pull/rabbit-update.txt | 2 +- 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 output/pull/fresh-clone-reset-then-pull.txt diff --git a/bats/branchout-projects.bats b/bats/branchout-projects.bats index c665b9d..a54ce13 100644 --- a/bats/branchout-projects.bats +++ b/bats/branchout-projects.bats @@ -58,6 +58,17 @@ frog-gemel" assert_success_file pull/fresh-clone-then-pull } +@test "project clone then reset to previous commit then pull again" { + example fresh-clone-reset-then-pull + run branchout project pull frog-gemel + assert_success_file pull/fresh-clone + cd frog/frog-gemel + git reset --hard HEAD^1 + cd ../.. + run branchout project pull frog-gemel + assert_success_file pull/fresh-clone-reset-then-pull +} + @test "a project with conflicts" { example conflicts run branchout project pull frog-bet diff --git a/branchout-project b/branchout-project index 9ea0d39..dc5f9f9 100755 --- a/branchout-project +++ b/branchout-project @@ -48,9 +48,18 @@ function projectUpdateError() { } function projectUpdate() { + local prePullHash + local postPullHash + cd "${PROJECTION_DIRECTORY}/${projectContext}" || usage "Failed to enter project directory" + prePullHash=$(git rev-parse HEAD 2>/dev/null) if git pull --ff-only origin > /dev/null 2>&1; then - projectContextStatus "${projectName}" "Pulled " + postPullHash=$(git rev-parse HEAD 2>/dev/null) + if test "${prePullHash}" = "${postPullHash}"; then + projectContextStatus "${projectName}" "Good " + else + projectContextStatus "${projectName}" "Pulled " + fi else projectUpdateError "${projectName}" "Failed " fi diff --git a/output/pull/fresh-clone-reset-then-pull.txt b/output/pull/fresh-clone-reset-then-pull.txt new file mode 100644 index 0000000..d0e2e85 --- /dev/null +++ b/output/pull/fresh-clone-reset-then-pull.txt @@ -0,0 +1 @@ +\033[0mPulled frog/frog-gemel\033[70D\033[70Cmaster\033[0m diff --git a/output/pull/fresh-clone-then-pull.txt b/output/pull/fresh-clone-then-pull.txt index d0e2e85..fbba463 100644 --- a/output/pull/fresh-clone-then-pull.txt +++ b/output/pull/fresh-clone-then-pull.txt @@ -1 +1 @@ -\033[0mPulled frog/frog-gemel\033[70D\033[70Cmaster\033[0m +\033[0mGood frog/frog-gemel\033[70D\033[70Cmaster\033[0m diff --git a/output/pull/lion-update.txt b/output/pull/lion-update.txt index c9dfee4..3d60264 100644 --- a/output/pull/lion-update.txt +++ b/output/pull/lion-update.txt @@ -1,2 +1,2 @@ \033[0mNothing lion\033[70D\033[70C\033[35mNot a repository\033[0m -\033[0mPulled lion/lion-aleph\033[70D\033[70Cmaster\033[0m +\033[0mGood lion/lion-aleph\033[70D\033[70Cmaster\033[0m diff --git a/output/pull/rabbit-update.txt b/output/pull/rabbit-update.txt index e0801c8..e1ecd53 100644 --- a/output/pull/rabbit-update.txt +++ b/output/pull/rabbit-update.txt @@ -1,2 +1,2 @@ \033[0mPulled rabbit\033[70D\033[70Cmaster\033[0m -\033[0mPulled rabbit/rabbit-aleph\033[70D\033[70Cmaster\033[0m +\033[0mGood rabbit/rabbit-aleph\033[70D\033[70Cmaster\033[0m