Create a new documentation branch with timestamp. Args: force: Force creation even if dirty working directory Returns: Branch name Raises: RepositoryError: If working directory is dirty (unless fo
(self, force: bool = False)
| 71 | return True, "Working directory is clean" |
| 72 | |
| 73 | def create_documentation_branch(self, force: bool = False) -> str: |
| 74 | """ |
| 75 | Create a new documentation branch with timestamp. |
| 76 | |
| 77 | Args: |
| 78 | force: Force creation even if dirty working directory |
| 79 | |
| 80 | Returns: |
| 81 | Branch name |
| 82 | |
| 83 | Raises: |
| 84 | RepositoryError: If working directory is dirty (unless force=True) |
| 85 | """ |
| 86 | # Check working directory |
| 87 | if not force: |
| 88 | is_clean, status_msg = self.check_clean_working_directory() |
| 89 | if not is_clean: |
| 90 | raise RepositoryError( |
| 91 | "Working directory has uncommitted changes.\n\n" |
| 92 | f"{status_msg}\n\n" |
| 93 | "Cannot create documentation branch with uncommitted changes.\n" |
| 94 | "Please commit or stash your changes first:\n" |
| 95 | " git status\n" |
| 96 | " git add -A && git commit -m \"Your message\"\n" |
| 97 | " # or\n" |
| 98 | " git stash\n\n" |
| 99 | "Then re-run: codewiki generate --create-branch" |
| 100 | ) |
| 101 | |
| 102 | # Generate branch name with timestamp |
| 103 | timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") |
| 104 | branch_name = f"docs/codewiki-{timestamp}" |
| 105 | |
| 106 | # Check if branch already exists (shouldn't happen with timestamp) |
| 107 | existing_branches = [b.name for b in self.repo.branches] |
| 108 | if branch_name in existing_branches: |
| 109 | # Append counter |
| 110 | counter = 1 |
| 111 | while f"{branch_name}-{counter}" in existing_branches: |
| 112 | counter += 1 |
| 113 | branch_name = f"{branch_name}-{counter}" |
| 114 | |
| 115 | try: |
| 116 | # Create and checkout new branch |
| 117 | new_branch = self.repo.create_head(branch_name) |
| 118 | new_branch.checkout() |
| 119 | return branch_name |
| 120 | except GitCommandError as e: |
| 121 | raise RepositoryError(f"Failed to create branch: {e}") |
| 122 | |
| 123 | def commit_documentation( |
| 124 | self, |
no test coverage detected