Skip to content

Commit

Permalink
Modify the way to displaying of commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dgparmar14 committed Apr 11, 2024
1 parent 519acbd commit 754242f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 9 additions & 6 deletions components/contributors/GithubActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ let renderText = (activity: Activity) => {
<div className="min-w-0 flex-1">
<div>
<p className="font-bold">
{activity.title}
pushed({activity?.commits?.length}) commits to {activity.branch}{" "}
in {activity.repo}{" "}
<span className="text-foreground">
<RelativeTime time={activity.time} />
</span>
Expand All @@ -176,12 +177,14 @@ let renderText = (activity: Activity) => {
<div className="mt-2 rounded-lg border border-secondary-600 p-2 md:p-4">
{activity?.commits?.map((commit, index) => (
<div key={index} className="mb-2 flex items-center">
<Link href={commit.link} target="_blank" className="flex gap-1">
<span className="text-sm font-medium text-foreground">
{index + 1}.
</span>{" "}
<Link
href={commit.link}
target="_blank"
className="flex gap-2 text-secondary-500"
>
<span>{commit.sha}</span>
<span className="cursor-pointer break-words text-sm font-medium text-foreground hover:text-primary-500">
{commit.text}
{commit.text.split("\n")[0]}
</span>
</Link>
</div>
Expand Down
7 changes: 5 additions & 2 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ export const ACTIVITY_TYPES = [
"pushed_commits",
] as const;

export interface commit {
export interface Commit {
link: string;
text: string;
sha: string;
}

export interface Activity {
Expand All @@ -80,7 +81,9 @@ export interface Activity {
time: string;
link: string;
text: string;
commits?: commit[];
branch?: string;
repo?: string;
commits?: Commit[];
collaborated_with?: string[];
turnaround_time?: number;
}
Expand Down
7 changes: 5 additions & 2 deletions scraper/src/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ def parse_event(self, event, event_time):
# Fetch full commit details
commit_details = requests.get(commit["url"], headers=self.headers).json()

if len(commit_details.get("parents", [])) in [0, 1]:
if len(commit_details.get("parents", [])) < 2:
# Prepare commit data
commit_data = {
"link": commit_details["html_url"],
"text": commit["message"],
"sha" : commit["sha"][-7:],
}
# Append commit data to the array
all_commits.append(commit_data)
Expand All @@ -196,7 +197,9 @@ def parse_event(self, event, event_time):
{
"type": "pushed_commits",
"time": event_time,
"title": f'Pushed({len(all_commits)}) commits to {event["repo"]["name"]}({branch})',
# "title": f'Pushed({len(all_commits)}) commits to {event["repo"]["name"]}({branch})',
"repo": event["repo"]["name"],
"branch": branch,
"commits": all_commits,
},
)
Expand Down

0 comments on commit 754242f

Please sign in to comment.