Open Akuli opened 2 years ago
I was thinking of just taking all lines containing url =
, but I looked at a couple .git/config
files I have on this computer:
$ grep 'url =' {porcu,typeshed}/.git/config
porcu/.git/config: url = https://akuli@github.com/Akuli/porcupine
porcu/.git/config:# url = ssh://akuli-thinkpad/home/akuli/porcu/.git
porcu/.git/config: url = https://github.com/python/typeshed
porcu/.git/config: url = https://github.com/python/typeshed
typeshed/.git/config: url = https://github.com/python/typeshed/
typeshed/.git/config: url = https://akuli@github.com/Akuli/typeshed
The typeshed
lines in porcu/.git/config
are from a Git submodule (that no longer exists):
[submodule "typeshed"]
url = https://github.com/python/typeshed
active = true
[submodule "typeshed2"]
url = https://github.com/python/typeshed
active = true
So if we decide to parse .git/config
, we can't just do line_containing_url.split("/")[-1]
. We have to do a few more things:
https://github.com/python/typeshed/
--> typeshed
.git
at the end if it is there: github.com/foo/bar.git
--> bar
foo/.git
doesn't turn into .git
and then into empty string as we split by slashTaking the first url =
line is probably best: I think any extra remotes you add afterwards will go to the end of the file (but I have to check this), and they are likely not your "primary" remote you usually pull and push to. An example would be adding the fork of another contributor with git remote add contributor https://github.com/contributor/projectname
.
I renamed my folder to porcupine
.
In the Shift+F5 dialog, you can say
{project_name}
and it will be substituted with the name of the project. This is great, except that it's unusable when I use a different folder name than the project's name, and then{project_name}
is wrongly the folder's name.Example: If I clone Porcupine to
/home/akuli/porcu
, so that I have/home/akuli/porcu/README.md
for example, then{project_name}
will be substituted withporcu
, not withporcupine
. This means commands likepython3 -m {project_name}
ormypy {project_name}
wrong.We could look in
.git/config
, if it exists. We don't have to parse it perfectly, because we can always use the folder's name as a fallback.