Skip to content

Fixed TypeError when commit is being null.#464

Open
AyushAgnihotri2025 wants to merge 1 commit intoanmol098:masterfrom
AyushAgnihotri2025:master
Open

Fixed TypeError when commit is being null.#464
AyushAgnihotri2025 wants to merge 1 commit intoanmol098:masterfrom
AyushAgnihotri2025:master

Conversation

@AyushAgnihotri2025
Copy link
Copy Markdown

@AyushAgnihotri2025 AyushAgnihotri2025 commented Jul 17, 2023

Closes #463
Closes #425

@AyushAgnihotri2025 AyushAgnihotri2025 changed the title Fixed TypeError commit is being null. Fixed TypeError when commit is being null. Jul 17, 2023
Copy link
Copy Markdown

@willnaoosmith willnaoosmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really test this right now, but looks like it should fix that issue.
BUT, if it doesn't, the code below should do the job for sure.

for commit in commit_data["data"]["repository"]["ref"]["target"]["history"]["nodes"]:
    try:
        if commit and commit["committedDate"]:
            date = search(r"\d+-\d+-\d+", commit["committedDate"]).group()
            curr_year = datetime.fromisoformat(date).year
            quarter = (datetime.fromisoformat(date).month - 1) // 3 + 1

            if repo_details["name"] not in date_data:
                date_data[repo_details["name"]] = dict()
            if branch["name"] not in date_data[repo_details["name"]]:
                date_data[repo_details["name"]][branch["name"]] = dict()
            date_data[repo_details["name"]][branch["name"]][commit["oid"]] = commit["committedDate"]

            if repo_details["primaryLanguage"] is not None:
                if curr_year not in yearly_data:
                    yearly_data[curr_year] = dict()
                if quarter not in yearly_data[curr_year]:
                    yearly_data[curr_year][quarter] = dict()
                if repo_details["primaryLanguage"]["name"] not in yearly_data[curr_year][quarter]:
                    yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]] = {"add": 0, "del": 0}
                yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]]["add"] += commit["additions"]
                yearly_data[curr_year][quarter][repo_details["primaryLanguage"]["name"]]["del"] += commit["deletions"]
    
    except Exception as error:
        DBM.p(f"A exception ocurred while getting the commit history! {str(error)}")
        continue

Thank you @AyushAgnihotri2025!

@willnaoosmith
Copy link
Copy Markdown

Merging when?

Copy link
Copy Markdown
Contributor

@thenithinbalaji thenithinbalaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge it asap?

@pseusys
Copy link
Copy Markdown
Collaborator

pseusys commented May 2, 2024

I personally can't merge the PR until the CI workflow runs successfully and I also can't launch the workflow. I think, it should be triggered on push. @AyushAgnihotri2025, @willnaoosmith, could you please make sure the workflow runs successfully and, if not, investigate logs and fix errors?

P.S. also, if it's not a big deal, I would prefer if commit is not None: syntax as it is more explicit and clear.

@willnaoosmith
Copy link
Copy Markdown

@pseusys it finally did run correctly again!
@AyushAgnihotri2025 Thanks for the help!

@ok-coder1
Copy link
Copy Markdown
Collaborator

I personally can't merge the PR until the CI workflow runs successfully and I also can't launch the workflow. I think, it should be triggered on push.

See #553

@TheGiraffe3
Copy link
Copy Markdown

@AyushAgnihotri2025 could you resolve conflicts?

@solusops
Copy link
Copy Markdown
Collaborator

solusops commented Apr 1, 2026

@pseusys Is this PR still valid now, code has undergone a lot of changes which may/may not have fixed the issues being addressed by the PR.
I cannot replicate the error.
Not closing the issue due to prior approvals from maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: 'NoneType' object is not subscriptable sys:1: RuntimeWarning: coroutine 'AsyncClient.get' was never awaited BUG : Action Fails

8 participants