Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension manager rewrite #467

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading