Skip to content

Commit

Permalink
Testing: git push auto fixed files (#4211)
Browse files Browse the repository at this point in the history
* chore(deps): update trufflesecurity/trufflehog docker tag to v3.82.12 (#4179)

* chore(deps): update dependency sfdx-hardis to v5.2.4 (#4178)

* changes from prev PR

* GitCommandError

* correcting git commands

* git config for commit user

* cause megalinter failure

* megalinter completes with warning on giterr

* azure pr comment active unless megalinter success

* Revert "azure pr comment active unless megalinter success"

This reverts commit d4fee10.

* error messaging and colours on git auto fixes

* logging icons

* git push origin but still need remoteBranchName

* git push remote branch

* remote_branch for ADO & BitBucket

* correcting cspell linter errors

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nicolas Vuillamy <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent a97b779 commit 177e834
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"RQASWB",
"SCSSLINT",
"SOURCEBRANCHNAME",
"SOURCEBRANCH",
"SOURCEREPOSITORYURI",
"St\u00e9phane",
"Suero",
Expand Down
16 changes: 13 additions & 3 deletions megalinter/reporters/UpdatedSourcesReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,27 @@ def produce_report(self):
if not config.exists(self.master.request_id, "GITHUB_REPOSITORY"):
apply_fixes = config.get(self.master.request_id, "APPLY_FIXES", "none")
if apply_fixes.lower() != "none":
SYSTEM_PULLREQUEST_SOURCEBRANCH = config.get(
self.master.request_id, "SYSTEM_PULLREQUEST_SOURCEBRANCH", ""
)
if SYSTEM_PULLREQUEST_SOURCEBRANCH != "":
remote_branch = SYSTEM_PULLREQUEST_SOURCEBRANCH
BITBUCKET_BRANCH = config.get(
self.master.request_id, "BITBUCKET_BRANCH", ""
)
if BITBUCKET_BRANCH != "":
remote_branch = BITBUCKET_BRANCH
try:
repo = git.Repo(os.path.realpath(self.master.github_workspace))
repo.config_writer().set_value("user", "name", "MegaLinter").release()
repo.config_writer().set_value("user", "email", "[email protected]").release()
repo.git.add(update=True)
repo.git.commit('-m', 'megalinter auto fixes')
repo.git.push()
except git.GitCommandError as giterr:
repo.git.push('origin', f'HEAD:{remote_branch}')
except git.GitCommandError as git_err:
logging.error(
c.red(
"❌ [Updated Sources Reporter] Failed to git push auto fixes: " + str(giterr.stderr)
"❌ [Updated Sources Reporter] Failed to git push auto fixes: " + str(git_err.stderr)
)
)
logging.warning(
Expand Down

0 comments on commit 177e834

Please sign in to comment.