- Blog
- Some repos on tangled
318 words2 min read
I finally mirrored some repositories on my tangled, motivated in part by the ridiculousness of GitHub lately. I should’ve probably written about some of the packages a while ago; bootstrapper is a package to bootstrap making other R packages, mostly according to my sensibilities of what new R packages should have. It updates steps in GHA and such as well. voucher is a R interface to Mitchell Hashimoto’s vouch.
I generated a quick nushell function which helped with quickly mirroring repos to tangled while keeping GH as the main source, for now:
def setup-tangled-remote [] {
let require_ok = {|result, msg|
if $result.exit_code != 0 {
error make {msg: $"($msg)\n($result.stderr | str trim)"}
}
}
let project = (
git rev-parse --show-toplevel
| str trim
| path basename
| str replace -a ' ' '-'
)
let origin_check = git remote get-url origin | complete
do $require_ok $origin_check "Remote 'origin' does not exist or has no URL."
let tangled_url = $"git@tangled.org:visruth.com/($project)"
let origin_url = $origin_check.stdout | str trim
let tangled_check = git ls-remote $tangled_url | complete
(do
$require_ok
$tangled_check
$"Tangled repo is missing or SSH auth failed: ($tangled_url)"
)
git remote set-url --push origin $origin_url
git remote set-url --add --push origin $tangled_url
git push -u origin --all
git push -u origin --tags
git remote -v
}
I also finally generated a simple nushell func I’ve been meaning to which deletes branches which aren’t on remote:
def git-remote-prune [
--force (-f) # use -D instead of -d
] {
git fetch --all --prune
let gone_branches = (
git for-each-ref refs/heads --format='%(refname:short)%09%(upstream:track)%09%(HEAD)'
| lines
| parse "{branch}\t{track}\t{head}"
| where track == "[gone]"
| where head != "*"
| get branch
)
if ($gone_branches | is-empty) {
print "No local branches with gone upstreams."
return
}
$gone_branches | each {|branch|
if $force {
git branch -D $branch
} else {
git branch -d $branch
}
}
}

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.