Skip to content

get changes in lines of code #47

get changes in lines of code

get changes in lines of code #47

Workflow file for this run

name: Doc-Pilot
on: push
permissions:
actions: read
contents: write
jobs:
add-docstring:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: DocPilot
persist-credentials: false
submodules: "recursive"
fetch-depth: 10
- name: Install GitPython
run: |
python -m pip install --upgrade pip
pip install gitpython
shell: bash
- name: Fetch Commit Changes
id: fetch_changes
run: |
import git
import json
repo = git.Repo(${{github.repository}})
commit = repo.head.commit
commit_changes = []
for diff in commit.diff(commit.parents[0]):
commit_changes.append({
"filename": diff.a_path,
"additions": diff.count("insertions"),
"deletions": diff.count("deletions"),
"changes": diff.count("lines")
})
print(json.dumps(commit_changes))
shell: python
- name: Display Commit Changes
run: |
commit_changes="${{ steps.fetch_changes.outputs }}"
echo "$commit_changes"
shell: bash