Skip to content

Commit

Permalink
Add Repo.from_project() constructor for correct initialization in f…
Browse files Browse the repository at this point in the history
…orks
  • Loading branch information
bswck committed Feb 2, 2024
1 parent 8a88068 commit ae33c5d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jaraco/develop/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import functools
import re
import pathlib
import posixpath
import itertools

import keyring
import nacl.public
import nacl.encoding
from requests_toolbelt import sessions

from . import git
from . import repo


Expand Down Expand Up @@ -42,8 +44,14 @@ def load_token():
return token

@classmethod
def detect(cls):
return cls(repo.get_project_metadata().project)
def from_project(cls, project, *, upstream=False):
if 'fork' in project.tags and not upstream:
return cls(posixpath.sep.join((username(), posixpath.basename(project))))
return cls(git.resolve(project).path[1:])

@classmethod
def detect(cls, *, upstream=False):
return cls.from_project(repo.get_project_metadata().project, upstream=upstream)

@functools.lru_cache()
def get_public_key(self):
Expand Down

0 comments on commit ae33c5d

Please sign in to comment.