Compare commits
4 Commits
f79230e1f9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 758d01ff1e | |||
| 8c8f123f5f | |||
| 74693a6b3a | |||
| 854c282983 |
5
fcl
5
fcl
@ -42,6 +42,9 @@ def repo_url(repo_str)
|
|||||||
# GitHub HTTPS. We like these, use it as-is.
|
# GitHub HTTPS. We like these, use it as-is.
|
||||||
when /^(git|https)\:\/\/github\.com\//
|
when /^(git|https)\:\/\/github\.com\//
|
||||||
repo_str
|
repo_str
|
||||||
|
# Some other HTTPS. This is probably fine too, as long as it ends with '.git'
|
||||||
|
when /^(git|https)\:\/\/.+\.git$/
|
||||||
|
repo_str
|
||||||
# GitHub SSH. Let's convert this to HTTPS.
|
# GitHub SSH. Let's convert this to HTTPS.
|
||||||
when /^git@github\.com\:.+\.git$/
|
when /^git@github\.com\:.+\.git$/
|
||||||
repo_str.sub(/^git@github\.com:/, 'https://github.com/')
|
repo_str.sub(/^git@github\.com:/, 'https://github.com/')
|
||||||
@ -63,7 +66,7 @@ def destination_path(repo_str)
|
|||||||
repo_elms = repo_str.split('/')
|
repo_elms = repo_str.split('/')
|
||||||
|
|
||||||
repo = repo_elms.pop.sub(/\.git$/, '')
|
repo = repo_elms.pop.sub(/\.git$/, '')
|
||||||
org = repo_elms.pop || Config['FCL_DEFAULT_ORG']
|
org = repo_elms.pop || Config.fetch('FCL_DEFAULT_ORG')
|
||||||
forge = repo_elms.pop || 'github.com'
|
forge = repo_elms.pop || 'github.com'
|
||||||
|
|
||||||
File.join(forge, org, repo)
|
File.join(forge, org, repo)
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#
|
#
|
||||||
cat <<-EOS
|
cat <<-EOS
|
||||||
repo () {
|
repo () {
|
||||||
cd \$($(dirname $(realpath ${BASH_SOURCE[0]}))/repo \$@)
|
r=\$($(dirname $(realpath ${BASH_SOURCE[0]}))/repo \$@)
|
||||||
|
[[ "\$r" != "." ]] && [[ "\$r" != "\$(pwd)/" ]] && cd \$r
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|||||||
9
repo
9
repo
@ -27,9 +27,14 @@ repos=$(find "${REPOSITORY_BASE}" -maxdepth 5 -name '.git' | sed "s|${REPOSITORY
|
|||||||
# Default to searching within github.com, because that's by far the most common
|
# Default to searching within github.com, because that's by far the most common
|
||||||
# place for repos to be.
|
# place for repos to be.
|
||||||
# selected=$(echo "${repos}" | gum filter --header="Pick a repo" --prompt="Repo: " --height=20 --value "github.com/${1}")
|
# selected=$(echo "${repos}" | gum filter --header="Pick a repo" --prompt="Repo: " --height=20 --value "github.com/${1}")
|
||||||
selected="$(echo "${repos}" | fzf -1 -0 -q "${REPO_DEFAULT_SEARCH_PREFIX}${1}" --prompt="Repo: ")"
|
selected="$(echo "${repos}" | fzf -1 -0 -q "${1:-${REPO_DEFAULT_SEARCH_PREFIX}}" --prompt="Repo: ")"
|
||||||
|
|
||||||
echo "${REPOSITORY_BASE}/${selected}"
|
# Do nothing if no repo was selected
|
||||||
|
if [ -n "${selected}" ]; then
|
||||||
|
echo "${REPOSITORY_BASE}/${selected}"
|
||||||
|
else
|
||||||
|
echo '.'
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO: It could be super nice to bias in favour of more frequently selected options.
|
# TODO: It could be super nice to bias in favour of more frequently selected options.
|
||||||
# For the last 500 uses (or so):
|
# For the last 500 uses (or so):
|
||||||
|
|||||||
Reference in New Issue
Block a user