Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output should indicate if a pull results in an update #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bats/branchout-projects.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion branchout-project
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much rather this said Current or Matches or UpToDate or something meaningful that fits rather than simply "Good". What if it's bad that there's no new change when you fetch?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or Unchanged or No change or ? I feel like any of the 5 suggestions I've given are better than Good but also that maybe there's a better word/phrase than any of them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing Good to something else is fine with me. Of those 5 suggestions which one do you like best?

else
projectContextStatus "${projectName}" "Pulled "
fi
else
projectUpdateError "${projectName}" "Failed "
fi
Expand Down
1 change: 1 addition & 0 deletions output/pull/fresh-clone-reset-then-pull.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\033[0mPulled frog/frog-gemel\033[70D\033[70Cmaster\033[0m
2 changes: 1 addition & 1 deletion output/pull/fresh-clone-then-pull.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
\033[0mPulled frog/frog-gemel\033[70D\033[70Cmaster\033[0m
\033[0mGood frog/frog-gemel\033[70D\033[70Cmaster\033[0m
2 changes: 1 addition & 1 deletion output/pull/lion-update.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion output/pull/rabbit-update.txt
Original file line number Diff line number Diff line change
@@ -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