-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync '--clean', fix bare_repos, additional tests
- Loading branch information
Showing
31 changed files
with
1,625 additions
and
169 deletions.
There are no files selected for viewing
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,40 @@ | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import cli_ui as ui | ||
|
||
from tsrc.executor import Outcome, Task | ||
from tsrc.repo import Repo | ||
|
||
|
||
class Cleaner(Task[Repo]): | ||
def __init__( | ||
self, | ||
workspace_path: Path, | ||
*, | ||
do_hard_clean: bool = False, | ||
) -> None: | ||
self.workspace_path = workspace_path | ||
self.do_hard_clean = do_hard_clean | ||
|
||
def describe_item(self, item: Repo) -> str: | ||
return item.dest | ||
|
||
def describe_process_start(self, item: Repo) -> List[ui.Token]: | ||
return ["Cleaning", item.dest] | ||
|
||
def describe_process_end(self, item: Repo) -> List[ui.Token]: | ||
return [ui.green, "ok", ui.reset, item.dest] | ||
|
||
def process(self, index: int, count: int, repo: Repo) -> Outcome: | ||
""" | ||
Clean each repo so it will be ready for next 'sync' | ||
""" | ||
self.info_count(index, count, "Cleaning", repo.dest) | ||
|
||
repo_path = self.workspace_path / repo.dest | ||
self.run_git(repo_path, "clean", "-f", "-d") | ||
if self.do_hard_clean is True: | ||
self.run_git(repo_path, "clean", "-f", "-X", "-d") | ||
|
||
return Outcome.empty() |
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
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
Oops, something went wrong.