Skip to content
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
7 changes: 6 additions & 1 deletion nb
Original file line number Diff line number Diff line change
Expand Up @@ -24484,7 +24484,12 @@ $(_color_primary "${_delete_action} branch on remote?") ($(_color_primary "${_cu

if [[ -z "${_new_branch:-}" ]]
then
_new_branch="${_current_branch}"
# Detect remote's default branch, fallback to local branch name
_new_branch="$(
git ls-remote --symref "${_new_remote_url}" HEAD 2>/dev/null \
| awk '/^ref:/ {sub(/refs\/heads\//, "", $2); print $2}'
)"
_new_branch="${_new_branch:-${_current_branch}}"
fi

if ! ((_skip_preamble))
Expand Down
4 changes: 2 additions & 2 deletions test/init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ load test_helper

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -76,7 +76,7 @@ load test_helper

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down
40 changes: 20 additions & 20 deletions test/notebooks-add.bats
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _setup_notebooks() {

printf "Example File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand All @@ -69,7 +69,7 @@ _setup_notebooks() {

printf "Sample File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "sample-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Sample Notebook" ls-remote \
Expand All @@ -85,7 +85,7 @@ _setup_notebooks() {

printf "Demo File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "demo-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Demo Notebook" ls-remote \
Expand Down Expand Up @@ -183,7 +183,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Example File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand All @@ -199,7 +199,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Sample File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "sample-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Sample Notebook" ls-remote \
Expand All @@ -215,7 +215,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Demo File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "demo-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Demo Notebook" ls-remote \
Expand Down Expand Up @@ -286,7 +286,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Example File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand All @@ -302,7 +302,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Sample File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "sample-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Sample Notebook" ls-remote \
Expand All @@ -318,7 +318,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

printf "Demo File One.md created.\\n"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "demo-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Demo Notebook" ls-remote \
Expand Down Expand Up @@ -390,7 +390,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "readme" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -424,7 +424,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -475,7 +475,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -522,7 +522,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -577,7 +577,7 @@ HEREDOC

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

"${_NB}" git status
"${_NB}" run ls -la
Expand Down Expand Up @@ -664,7 +664,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

"${_NB}" git status
"${_NB}" run ls -la
Expand Down Expand Up @@ -751,7 +751,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

"${_NB}" git status
"${_NB}" run ls -la
Expand Down Expand Up @@ -818,7 +818,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

"${_NB}" git status
"${_NB}" run ls -la
Expand Down Expand Up @@ -885,7 +885,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

"${_NB}" git status
"${_NB}" run ls -la
Expand Down Expand Up @@ -946,7 +946,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

_sed_i "s/master/example-branch/" "${_GIT_REMOTE_PATH}/HEAD"

Expand Down Expand Up @@ -996,7 +996,7 @@ Press\ .*enter.*\ to\ use\ the\ selected\ name,\ .*type.*\ a\ new\ name,\ or\ pr

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "master" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/home" ls-remote \
Expand Down
4 changes: 2 additions & 2 deletions test/notebooks-init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Initialized\ local\ notebook:\ .*${_TMP_DIR}/target-directory ]]

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down Expand Up @@ -149,7 +149,7 @@ Initialized\ local\ notebook:\ .*${_TMP_DIR}/target-directory ]]

"${_NB}" add "Example File One.md" --content "Example content one."

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/Example Notebook" ls-remote \
Expand Down
4 changes: 2 additions & 2 deletions test/remote-remove.bats
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ load test_helper

"${_NB}" git branch -m "example-branch"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<("${_NB}" remote) \
Expand Down Expand Up @@ -511,7 +511,7 @@ load test_helper

"${_NB}" git branch -m "example-branch"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<("${_NB}" remote) \
Expand Down
8 changes: 4 additions & 4 deletions test/remote-set.bats
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Remote\ set\ to:\ .*${_GIT_REMOTE_URL}.*\ \(.*master.*\) ]]
"${_NB}" git branch -m "sample-branch"
}

run "${_NB}" remote set "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}1${_NEWLINE}q${_NEWLINE}"
run "${_NB}" remote set "${_GIT_REMOTE_URL}" "sample-branch" <<< "y${_NEWLINE}1${_NEWLINE}q${_NEWLINE}"

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"
Expand Down Expand Up @@ -500,7 +500,7 @@ Remote\ set\ to:\ .*${_GIT_REMOTE_URL}.*\ \(.*master.*\) ]]
"${_NB}" git branch -m "sample-branch"
}

run "${_NB}" remote set "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}q${_NEWLINE}"
run "${_NB}" remote set "${_GIT_REMOTE_URL}" "sample-branch" <<< "y${_NEWLINE}q${_NEWLINE}"

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"
Expand Down Expand Up @@ -1212,7 +1212,7 @@ Remote\ set\ to:\ .*${_GIT_REMOTE_URL}.*\ \(.*master.*\) ]]
_setup_remote_repo
}

run "${_NB}" remote set "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
run "${_NB}" remote set "${_GIT_REMOTE_URL}" "example" <<< "y${_NEWLINE}2${_NEWLINE}"

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"
Expand Down Expand Up @@ -1272,7 +1272,7 @@ Remote\ set\ to:\ .*${_GIT_REMOTE_URL}.*\ \(.*example.*\) ]]
_setup_remote_repo
}

run "${_NB}" remote set "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}1${_NEWLINE}1${_NEWLINE}"
run "${_NB}" remote set "${_GIT_REMOTE_URL}" "example" <<< "y${_NEWLINE}1${_NEWLINE}1${_NEWLINE}"

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"
Expand Down
2 changes: 1 addition & 1 deletion test/remote.bats
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Remote\ set\ to:\ .*${_GIT_REMOTE_URL}.*\ \(.*master.*\) ]]

"${_NB}" git branch -m "example-branch"

"${_NB}" remote add "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}2${_NEWLINE}"
"${_NB}" remote add "${_GIT_REMOTE_URL}" "example-branch" <<< "y${_NEWLINE}2${_NEWLINE}"

diff \
<(git -C "${NB_DIR}/home" ls-remote \
Expand Down
Loading