You've already forked wakapi-readme-stats
single commit option added
This commit is contained in:
@@ -20,5 +20,6 @@ INPUT_SHOW_UPDATED_DATE=True
|
||||
INPUT_UPDATED_DATE_FORMAT=%d/%m/%Y %H:%M:%S
|
||||
INPUT_COMMIT_BY_ME=True
|
||||
INPUT_COMMIT_MESSAGE=Updated with Dev Metrics
|
||||
INPUT_COMMIT_SINGLE=True
|
||||
INPUT_DEBUG_LOGGING=True
|
||||
DEBUG_RUN=True
|
||||
|
||||
@@ -112,6 +112,11 @@ inputs:
|
||||
description: "Git commit custom email"
|
||||
default: ""
|
||||
|
||||
COMMIT_SINGLE:
|
||||
required: false
|
||||
description: "Erase commit history on each commit"
|
||||
default: "False"
|
||||
|
||||
LOCALE:
|
||||
required: false
|
||||
description: "Show stats in your own language"
|
||||
|
||||
@@ -38,6 +38,7 @@ class EnvironmentManager:
|
||||
COMMIT_MESSAGE = getenv("INPUT_COMMIT_MESSAGE", "Updated with Dev Metrics")
|
||||
COMMIT_USERNAME = getenv("INPUT_COMMIT_USERNAME", "")
|
||||
COMMIT_EMAIL = getenv("INPUT_COMMIT_EMAIL", "")
|
||||
COMMIT_SINGLE = getenv("INPUT_COMMIT_SINGLE", "").lower() in _TRUTHY
|
||||
|
||||
LOCALE = getenv("INPUT_LOCALE", "en")
|
||||
UPDATED_DATE_FORMAT = getenv("INPUT_UPDATED_DATE_FORMAT", "%d/%m/%Y %H:%M:%S")
|
||||
|
||||
@@ -30,6 +30,7 @@ class GitHubManager:
|
||||
|
||||
_REMOTE_NAME: str
|
||||
_REMOTE_PATH: str
|
||||
_SINGLE_COMMIT_BRANCH = "latest_branch"
|
||||
|
||||
_START_COMMENT = f"<!--START_SECTION:{EM.SECTION_NAME}-->"
|
||||
_END_COMMENT = f"<!--END_SECTION:{EM.SECTION_NAME}-->"
|
||||
@@ -55,7 +56,8 @@ class GitHubManager:
|
||||
GitHubManager.REPO = Repo.clone_from(GitHubManager._REPO_PATH, to_path=clone_path)
|
||||
|
||||
GitHubManager.REPO.git.checkout(GitHubManager.branch())
|
||||
# TODO: delete and recreate branch if single commit
|
||||
if EM.COMMIT_SINGLE:
|
||||
GitHubManager.REPO.git.checkout("--orphan", GitHubManager._SINGLE_COMMIT_BRANCH)
|
||||
|
||||
@staticmethod
|
||||
def _get_author() -> Actor:
|
||||
@@ -147,8 +149,15 @@ class GitHubManager:
|
||||
actor = GitHubManager._get_author()
|
||||
DBM.i("Committing files to repo...")
|
||||
GitHubManager.REPO.index.commit(EM.COMMIT_MESSAGE, author=actor, committer=actor)
|
||||
|
||||
if EM.COMMIT_SINGLE:
|
||||
DBM.i("Pushing files to repo as a single commit...")
|
||||
refspec = f"{GitHubManager._SINGLE_COMMIT_BRANCH}:{GitHubManager.branch()}"
|
||||
headers = GitHubManager.REPO.remotes.origin.push(force=True, refspec=refspec)
|
||||
else:
|
||||
DBM.i("Pushing files to repo...")
|
||||
headers = GitHubManager.REPO.remote(name="origin").push()
|
||||
headers = GitHubManager.REPO.remotes.origin.push()
|
||||
|
||||
if len(headers) == 0:
|
||||
DBM.i(f"Repository push error: {headers}!")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user