-
Notifications
You must be signed in to change notification settings - Fork 2
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
Do not change Git user custom config #108
Do not change Git user custom config #108
Conversation
MegaLinter status:
|
Descriptor | Linter | Files | Fixed | Errors | Elapsed time |
---|---|---|---|---|---|
✅ ACTION | actionlint | 11 | 0 | 0.2s | |
✅ BASH | bash-exec | 4 | 0 | 0.02s | |
✅ BASH | shellcheck | 4 | 0 | 0.01s | |
✅ BASH | shfmt | 4 | 0 | 0.01s | |
✅ COPYPASTE | jscpd | yes | no | 2.26s | |
✅ CREDENTIALS | secretlint | yes | no | 2.76s | |
✅ DOCKERFILE | dockerfilelint | 1 | 0 | 0.23s | |
✅ DOCKERFILE | hadolint | 1 | 0 | 0.07s | |
✅ GIT | git_diff | yes | no | 0.07s | |
✅ JSON | eslint-plugin-jsonc | 8 | 0 | 0.84s | |
✅ JSON | jsonlint | 8 | 0 | 1.9s | |
✅ JSON | prettier | 8 | 0 | 0.53s | |
✅ JSON | v8r | 8 | 0 | 5.22s | |
markdownlint | 15 | 1 | 0.38s | ||
✅ MARKDOWN | markdown-link-check | 15 | 0 | 17.21s | |
✅ MARKDOWN | markdown-table-formatter | 15 | 0 | 0.23s | |
✅ PYTHON | bandit | 109 | 0 | 1.11s | |
✅ PYTHON | black | 109 | 0 | 1.74s | |
✅ PYTHON | flake8 | 109 | 0 | 1.18s | |
✅ PYTHON | isort | 109 | 0 | 0.23s | |
✅ PYTHON | mypy | 109 | 0 | 40.07s | |
✅ PYTHON | pylint | 109 | 0 | 12.09s | |
✅ SPELL | cspell | 159 | 0 | 4.96s | |
✅ SPELL | misspell | 159 | 0 | 0.07s | |
✅ YAML | prettier | 16 | 0 | 0.77s | |
✅ YAML | v8r | 16 | 0 | 10.05s | |
✅ YAML | yamllint | 16 | 0 | 0.26s |
See errors details in artifact MegaLinter reports on CI Job page
@yeraydavidrodriguez @da2ce7 the change is already implemented but I would like to refactor the from git import Repo
class GitRepo:
"""A wrapper for GitPython Repo"""
def __init__(self, git_repo_dir, git_user, gnupghome="~/.gnupg"):
self.repo = Repo(git_repo_dir)
self.git_user = git_user
self.gnupghome = gnupghome
def commit(self, filepaths, commit_message: str, env: dict[str, str] = {}):
"""
It creates a commit.
Filepath is an object with four optional file lists:
{
"added": [],
"deleted": [],
"modified": [],
"renamed": [],
}
"""
if "added" in filepaths:
self.repo.index.add(filepaths["added"])
if "deleted" in filepaths:
self.repo.index.remove(filepaths["deleted"])
if "renamed" in filepaths:
self.repo.index.add(filepaths["renamed"]["new"])
self.repo.index.remove(filepaths["renamed"]["old"])
# Write index. Needed for commit with signature:
# https://github.com/gitpython-developers/GitPython/issues/580#issuecomment-282474086
self.repo.index.write()
# Unsigned commit
if self.git_user.signingkey is None:
with self.repo.git.custom_environment(**env):
return self.repo.git.commit("-m", f"{commit_message}")
# Signed commit
with self.repo.git.custom_environment(GNUPGHOME=self.gnupghome, **env):
return self.repo.git.commit(
"-S",
f"--gpg-sign={self.git_user.signingkey}",
"-m",
f"{commit_message}",
) @yeraydavidrodriguez and I agreed some weeks ago that we should not couple this mod to the specific data structure used by the TODO:
The TODO:
|
@da2ce7 @yeraydavidrodriguez I changed my mind. I tend to make PR too big. I've created a new issue for the refactoring. I'm going to merge this fix and release a new minor version and test that the new version works fine with our Library and Website. |
We were changing the Git committer configuration. We should not do that and rely on preset configuration. We only should allow the user to overwrite committer and author emails and names by passing those arguments to the git commit command (via env vars or commits options).