-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
275 additions
and
1,262 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
from __future__ import annotations | ||
from datetime import datetime | ||
from typing import List, Set | ||
from releasy.old.repository_old import Repository | ||
|
||
|
||
class Commit: | ||
""" | ||
A change in a release, such as a commit | ||
""" | ||
def __init__(self, id: str, parents: List[Commit], timestamp: datetime) -> None: | ||
self._id = id | ||
self.parents = parents | ||
self.timestamp = datetime | ||
|
||
@property | ||
def id(self) -> str: | ||
return self._id | ||
|
||
def __hash__(self) -> int: | ||
if self.id: | ||
return hash(self.id) | ||
else: | ||
return super.__hash__() | ||
|
||
def __eq__(self, other: object) -> bool: | ||
if not isinstance(other, Commit): | ||
return False | ||
|
||
return self.id == other.id | ||
|
||
|
||
class CommitGroup: | ||
def __init__(self, commits: CommitSet = None): | ||
self._all = commits | ||
|
||
@property | ||
def all(self) -> Set[Commit]: | ||
return self._all | ||
|
||
def add(self, commits: Set[Commit]) -> None: | ||
for commit in commits: | ||
self._all.add(commit) | ||
|
||
|
||
class CommitSet: | ||
def __init__(self, commits: Set[Commit] = None): | ||
if not commits: | ||
self._commits = {} | ||
else: | ||
self._commits = {commit.id: commit for commit in commits} | ||
|
||
def __len__(self) -> int: | ||
return len(self._commits) | ||
|
||
def add(self, commit: Commit) -> None: | ||
self._commits[commit.id] = commit | ||
|
||
def __getitem__(self, commit_id: str) -> Commit: | ||
if commit_id not in self._commits: | ||
return KeyError(f"Commit {commit_id} not found") | ||
return self._commits[commit_id] | ||
|
||
|
||
class ChangeAssignmentStrategy: | ||
pass | ||
|
||
|
||
class HistoryBasedStrategy(ChangeAssignmentStrategy): | ||
def assign(releases: Set, repository: Repository): | ||
return releases | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
|
||
@pytest.fixture | ||
def alice() -> Contributor: | ||
return Contributor("ALICE") | ||
return Contributor("Alice") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.