can clone git repos now

master
Jordan Orelli 2 years ago
parent 28ca2e9e14
commit dcce2810f9

@ -17,7 +17,26 @@ files:
# [run vim-plugins] # [run vim-plugins]
# when: host.has('vim') # when: host.has('vim')
# cmd: vim +PluginInstall +qall # cmd: vim +PluginInstall +qall
#
[link-files neovim:windows]
when: host.is_windows and host.has('nvim')
target_root: ~/AppData/Local
files:
nvim/lua
.vim/ftplugin > nvim/ftplugin
.vimrc > nvim/init.vim
Vundle.vim > nvim/bundle/Vundle.vim
[git packer-posix]
when: not host.is_windows
repo: https://github.com/wbthomason/packer.nvim
target: ~/.local/share/nvim/site/pack/packer/start/packer.nvim
[git packer-windows]
when: host.is_windows
repo: https://github.com/wbthomason/packer.nvim
target: ~/AppData/Local/nvim-data/site/pack/packer/start/packer.nvim
# [run nvim-plugins] # [run nvim-plugins]
# when: host.has('nvim') # when: host.has('nvim')
# cmd: nvim +PluginInstall +qall # cmd: nvim +PluginInstall +qall
@ -50,15 +69,6 @@ files: nvim/init.vim > .config/nvim/init.vim
when: host.is_wsl when: host.is_wsl
files: scripts/winmode > bin/winmode files: scripts/winmode > bin/winmode
[link-files neovim:windows]
when: host.is_windows and host.has('nvim')
target_root: ~/AppData/Local
files:
nvim/lua
.vim/ftplugin > nvim/ftplugin
.vimrc > nvim/init.vim
Vundle.vim > nvim/bundle/Vundle.vim
packer.nvim > nvim-data/site/pack/packer/start/packer.nvim
[link-files vscode:windows] [link-files vscode:windows]
when: host.is_windows and host.has('code') when: host.is_windows and host.has('code')

@ -0,0 +1,24 @@
import subprocess
from pathlib import Path
from . import log
class Repo:
resource_name = 'git'
def __init__(self, label, section):
self.label = label or None
self.repo = section['repo']
self.target = Path(section['target']).expanduser()
def run(self):
if self.target.exists():
log.debug("target exists")
if self.target.is_dir():
log.debug("target is dir")
git_dir = self.target / ".git"
if git_dir.exists() and git_dir.is_dir():
log.debug("target is git repo")
return
cmd = ["git", "clone", self.repo, self.target]
subprocess.call(cmd)

@ -45,7 +45,10 @@ class Linker:
print(f"rm {target_path} (broken symlink)") print(f"rm {target_path} (broken symlink)")
target_path.unlink() target_path.unlink()
target_path.symlink_to(source_path) try:
target_path.symlink_to(source_path)
except PermissionError as e:
print(f"ERROR creating link: {e}")
print(f"link {target_path} -> {source_path}") print(f"link {target_path} -> {source_path}")
class LinkFiles: class LinkFiles:

@ -2,9 +2,10 @@ from .home import Home
from .linker import LinkFiles from .linker import LinkFiles
from .cargo import CargoInstall from .cargo import CargoInstall
from .run import Run from .run import Run
from . import git
class Resource: class Resource:
resource_types = [Home, LinkFiles, CargoInstall, Run] resource_types = [Home, LinkFiles, CargoInstall, Run, git.Repo]
@classmethod @classmethod
def from_name(cls, name): def from_name(cls, name):

Loading…
Cancel
Save