MCPcopy Create free account
hub / github.com/ChicagoHAI/NeuriCo / commit_and_push

Method commit_and_push

src/core/github_manager.py:247–324  ·  view source on GitHub ↗

Commit all changes and push to GitHub. Args: repo_path: Path to local repository commit_message: Commit message branch: Branch name (default: main) Returns: True if successful

(self,
                       repo_path: Path,
                       commit_message: str,
                       branch: str = "main")

Source from the content-addressed store, hash-verified

245 return repo
246
247 except GitCommandError as e:
248 raise RuntimeError(f"Failed to clone repository: {e}")
249
250 def commit_and_push(self,
251 repo_path: Path,
252 commit_message: str,
253 branch: str = "main") -> bool:
254 """
255 Commit all changes and push to GitHub.
256
257 Args:
258 repo_path: Path to local repository
259 commit_message: Commit message
260 branch: Branch name (default: main)
261
262 Returns:
263 True if successful
264 """
265 if not GITPYTHON_AVAILABLE:
266 raise ImportError("GitPython is required. Install with: pip install GitPython")
267
268 print(f"\n📝 Committing and pushing changes...")
269
270 try:
271 repo = Repo(repo_path)
272
273 # Configure git user (if not set)
274 try:
275 repo.config_reader().get_value("user", "name")
276 except:
277 # Set default user
278 with repo.config_writer() as git_config:
279 git_config.set_value("user", "name", "NeuriCo")
280 git_config.set_value("user", "email", "noreply@neurico.dev")
281
282 # Sanitize log files before adding (remove any leaked API keys)
283 logs_dir = Path(repo_path) / "logs"
284 if logs_dir.exists():
285 sanitized_count = sanitize_logs_directory(logs_dir)
286 if sanitized_count > 0:
287 print(f" ✓ Sanitized {sanitized_count} log file(s)")
288
289 # Add all files
290 repo.git.add(A=True)
291
292 # Unstage files exceeding GitHub's 100MB file size limit
293 large_files = self._unstage_large_files(repo, repo_path)
294 if large_files:
295 for lf_path, lf_size in large_files:
296 size_mb = lf_size / (1024 * 1024)
297 print(f" ⚠️ Skipped large file ({size_mb:.1f}MB > 100MB limit): {lf_path}")
298 print(f" ⚠️ {len(large_files)} file(s) excluded from commit due to GitHub's 100MB file size limit.")
299 print(f" These files remain in your local workspace but are not pushed to GitHub.")
300
301 # Check if there are changes to commit
302 if repo.is_dirty(untracked_files=True):
303 # Commit
304 repo.index.commit(commit_message)

Callers 6

mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
run_researchMethod · 0.80
run_comment_modeMethod · 0.80
_finalize_researchMethod · 0.80

Calls 3

_unstage_large_filesMethod · 0.95
sanitize_logs_directoryFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected