Skip to content

Commit

Permalink
Check for untracked files before any command
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyburdi committed Jul 19, 2023
1 parent 85a39d0 commit 77612ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 0 additions & 2 deletions ge_releaser/cmd/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
def prep(git: GitService) -> None:
click.secho("[prep]", bold=True, fg="blue")

git.verify_no_untracked_files()

last_version, release_version = _parse_versions(git)

git.checkout_and_pull_trunk()
Expand Down
9 changes: 9 additions & 0 deletions ge_releaser/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ class GxFile(str, enum.Enum):
TEAMS = ".github/teams.yml"
DOCS_DATA_COMPONENT = "docs/docusaurus/docs/components/_data.jsx"
DOCS_CONFIG = "docs/docusaurus/docusaurus.config.js"


FILES_TO_COMMIT = (
GxFile.CHANGELOG_MD,
GxFile.DOCS_DATA_COMPONENT,
GxFile.DOCS_CONFIG,
GxFile.CHANGELOG_RST,
GxFile.DEPLOYMENT_VERSION,
)
18 changes: 7 additions & 11 deletions ge_releaser/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import github
from github.PullRequest import PullRequest

from ge_releaser.constants import GxFile, FILES_TO_COMMIT


class GitService:
def __init__(
self,
Expand Down Expand Up @@ -35,22 +38,15 @@ def checkout_and_pull_trunk(self) -> None:
self._git.git.checkout(self._trunk)
self._git.git.pull(self._remote, self._trunk)

def check_for_untracked_files(self) -> bool:
return bool(self._git.git.untracked_files)
def _check_for_untracked_files(self) -> bool:
return bool(self._git.untracked_files or self._git.unstaged_files)

def verify_no_untracked_files(self) -> None:
if self.check_for_untracked_files():
if self._check_for_untracked_files():
raise ValueError("There are untracked files. Please make sure to run this step with a clean repo.")

def stage_all_and_commit(self, message: str) -> None:
files_to_add = (
"docs/docusaurus/docs/changelog.md",
"docs/docusaurus/docs/components/_data.jsx",
"docs/docusaurus/docusaurus.config.js",
"docs_rtd/changelog.rst",
"great_expectations/deployment_version",
)
self._git.git.add(files_to_add)
self._git.git.add(FILES_TO_COMMIT)
self._git.git.commit("-m", message, "--no-verify")

def get_release_timestamp(self, version: str) -> dt.datetime:
Expand Down
1 change: 1 addition & 0 deletions ge_releaser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ def setup(ctx: click.Context) -> None:
git = GitService(
github_token=token, repo_name=GITHUB_REPO, trunk=TRUNK, remote=REMOTE
)
git.verify_no_untracked_files()
ctx.obj = git

0 comments on commit 77612ea

Please sign in to comment.