⬅︎ Back to Git + Twitter = Friedcode
Python's os.path.basename, basename from coreutils and busybox's basename all do the "right thing" with your example string.On my systems, running 1.6.2.3, I'd use `git config --get remote.origin.url' to get for example "git@github.com:JNRowe/misc-overlay.git"
Great! Thank you for that sed command. About the second one-liner, it's the git info returns this: "== Remote URL: origin ssh://root@git.fry-it.com/var/cache/git/waf" So basename wouldn't work on that. I'm using 1.5.6.3 from Ubuntu to get git info.
I think I know what you mean but the whole string starts with "== Remote URL: " which means that basename fails on it. $ repo_name=`git info | head -n1` $ basename $repo_name basename: extra operand `URL:' Try `basename --help' for more information.
My fault, I should have used an example.basename "$repo_name"it is the quoting that is important, it makes basename treat the string as an ugly space and symbol including filename
Comment
Python's os.path.basename, basename from coreutils and busybox's basename all do the "right thing" with your example string.
On my systems, running 1.6.2.3, I'd use `git config --get remote.origin.url' to get for example "git@github.com:JNRowe/misc-overlay.git"
Parent comment
Great! Thank you for that sed command. About the second one-liner, it's the git info returns this: "== Remote URL: origin ssh://root@git.fry-it.com/var/cache/git/waf" So basename wouldn't work on that. I'm using 1.5.6.3 from Ubuntu to get git info.
Replies
I think I know what you mean but the whole string starts with "== Remote URL: " which means that basename fails on it.
$ repo_name=`git info | head -n1`
$ basename $repo_name
basename: extra operand `URL:'
Try `basename --help' for more information.
My fault, I should have used an example.
basename "$repo_name"
it is the quoting that is important, it makes basename treat the string as an ugly space and symbol including filename