-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Add functions to clean Git lock files locally and remotely #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d8be706
42f859c
5e5d711
0193fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,11 @@ | ||||||||||||||||||||||||||||||||||
| import concurrent.futures | ||||||||||||||||||||||||||||||||||
| import glob | ||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||
| import paramiko | ||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||
| import platform | ||||||||||||||||||||||||||||||||||
| import shlex | ||||||||||||||||||||||||||||||||||
| import socket | ||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||||
|
|
@@ -127,7 +130,57 @@ def _set_branch_variables(self): | |||||||||||||||||||||||||||||||||
| self.utils.set_env_var( | ||||||||||||||||||||||||||||||||||
| "GITHUB_RUN_ATTEMPT", self.run_attempt, os.getenv("GITHUB_ENV", "") | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def clean_git_locks(self, repo_path): | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| """clean .git/*.lock files in a local repository""" | ||||||||||||||||||||||||||||||||||
| git_dir = os.path.join(repo_path, '.git') | ||||||||||||||||||||||||||||||||||
| if not os.path.exists(git_dir): | ||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| lock_files = glob.glob(os.path.join(git_dir, '*.lock')) | ||||||||||||||||||||||||||||||||||
| for lock_file in lock_files: | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| os.remove(lock_file) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+136
to
+143
|
||||||||||||||||||||||||||||||||||
| git_dir = os.path.join(repo_path, '.git') | |
| if not os.path.exists(git_dir): | |
| return | |
| lock_files = glob.glob(os.path.join(git_dir, '*.lock')) | |
| for lock_file in lock_files: | |
| try: | |
| os.remove(lock_file) | |
| git_dir = Path(repo_path) / ".git" | |
| if not git_dir.exists(): | |
| return | |
| lock_files = git_dir.glob("*.lock") | |
| for lock_file in lock_files: | |
| try: | |
| lock_file.unlink() |
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AutoAddPolicy allows any SSH host key without verification, which is a security risk. This could make the connection vulnerable to man-in-the-middle attacks. However, I note that the existing _execute_remote_command method (line 346) also uses AutoAddPolicy, so this is consistent with the current codebase pattern. If this pattern is acceptable for your infrastructure (e.g., trusted internal network), this is fine. Otherwise, consider using a more secure approach like RejectPolicy with properly configured known_hosts.
| ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| # Load known host keys and reject unknown hosts to avoid MITM vulnerabilities | |
| ssh.load_system_host_keys() | |
| user_known_hosts = os.path.expanduser("~/.ssh/known_hosts") | |
| if os.path.exists(user_known_hosts): | |
| ssh.load_host_keys(user_known_hosts) | |
| ssh.set_missing_host_key_policy(paramiko.RejectPolicy()) |
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
tomchon marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function calls self.clean_git_locks_remote(host, username, ...) but doesn't provide the required password or key_filename parameters that are needed for SSH authentication. Looking at the host_config structure used elsewhere in the code (e.g., line 349-352), these parameters should be extracted from host_config if available, or the function should handle authentication properly. Without proper authentication parameters, the SSH connection will fail.
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function calls self.clean_git_locks_remote(host, username, ...) but doesn't provide the required password or key_filename parameters that are needed for SSH authentication. Looking at the host_config structure used elsewhere in the code (e.g., line 349-352), these parameters should be extracted from host_config if available, or the function should handle authentication properly. Without proper authentication parameters, the SSH connection will fail.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -109,7 +109,7 @@ jobs: | |||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| repository: "taosdata/.github" | ||||||
| ref: "main" | ||||||
| ref: "fix/clean-git-locks" | ||||||
|
||||||
| ref: "fix/clean-git-locks" | |
| ref: "main" |
Uh oh!
There was an error while loading. Please reload this page.