Skip to content

Commit

Permalink
feat: Clone extension repository directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Dec 4, 2024
1 parent c27189b commit 6c883bc
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 161 deletions.
44 changes: 0 additions & 44 deletions extensions/dev.py

This file was deleted.

25 changes: 25 additions & 0 deletions fetch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import re

import git

URL = re.compile(r"^(?:http)s?://")


class Git(git.Git):
def clone(self, url: str, dir: str) -> str:
if not URL.match(url):
# assumes github as repo host
url = f"http://github.com/{url}"

if name := self.repo_name(url):
dir = os.path.join(dir, name)
git.Repo(self).clone_from(url, dir)
return dir

raise Exception(f"The url `{url}` does not point to a git repo")

def repo_name(self, url: str) -> None:
match = re.search(r"/([^/]+?)(\.git)?$", url)
if match:
return match.group(1)
12 changes: 8 additions & 4 deletions src/biscuit/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ def open_directory(self, dir: str) -> None:
self.terminalmanager.open_terminal()

try:
self.git.check_git()
self.update_git()
self.git_found, self.git.repo = self.git.check_git()
if self.git_found:
self.notifications.info("Git repository found in opened directory")
self.logger.info("Git repository found in opened directory")
self.git.update_repo_info()
self.update_git_GUI()
except Exception as e:
self.logger.error(f"Checking git failed: {e}")
self.notifications.error("Checking git failed: see logs")
Expand All @@ -98,7 +102,7 @@ def open_directory(self, dir: str) -> None:

self.event_generate("<<DirectoryChanged>>", data=dir)

def update_git(self) -> None:
def update_git_GUI(self) -> None:
self.statusbar.update_git_info()
self.source_control.refresh()

Expand Down Expand Up @@ -137,7 +141,7 @@ def close_active_directory(self) -> None:
self.editorsmanager.delete_all_editors()
self.set_title()
self.git_found = False
self.update_git()
self.update_git_GUI()
self.event_generate("<<DirectoryChanged>>")

def close_active_editor(self) -> None:
Expand Down
Loading

0 comments on commit 6c883bc

Please sign in to comment.