Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use first commit for repo age#2667

Closed
hardikmodha wants to merge 22 commits intorefined-github:masterfrom
hardikmodha:use_first_commit_for_repo_age
Closed

Use first commit for repo age#2667
hardikmodha wants to merge 22 commits intorefined-github:masterfrom
hardikmodha:use_first_commit_for_repo_age

Conversation

@hardikmodha
Copy link
Contributor

Closes #2660

Using the latest commit available on the repo root and the total number of commits to fetch the oldest commit.

Test

  1. https://github.com/sindresorhus/refined-github
  2. https://github.com/nodejs/node
  3. https://github.com/python/cpython

@hardikmodha hardikmodha force-pushed the use_first_commit_for_repo_age branch from a52da6a to b486593 Compare January 5, 2020 17:04
Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Looks great!

Just a thought for now, but perhaps it would be nice to also link to that first commit since we have the information on the same page and every piece in the summary is also a link.

@yakov116
Copy link
Member

yakov116 commented Jan 5, 2020

@fregante should we fall back to the old way if there are no commits?

@fregante
Copy link
Member

fregante commented Jan 5, 2020

should we fall back to the old way if there are no commits?

I don't think anybody cares about repos without commits 😄

At most we can prevent the error by using if count === 0, return false

@hardikmodha
Copy link
Contributor Author

I think just returning makes sense, saves us an unnecessary request.

@hardikmodha hardikmodha force-pushed the use_first_commit_for_repo_age branch from 98c5a62 to e06ffd5 Compare January 5, 2020 17:55
@hardikmodha hardikmodha marked this pull request as ready for review January 5, 2020 17:59
@hardikmodha hardikmodha requested a review from fregante January 5, 2020 17:59
@hardikmodha
Copy link
Contributor Author

hardikmodha commented Jan 5, 2020

Just a thought for now, but perhaps it would be nice to also link to that first commit since we have the information on the same page and every piece in the summary is also a link.

Makes sense. Each and every item is a link in summary we can do that.

@hardikmodha
Copy link
Contributor Author

@fregante I have incorporated the changes to point to the oldest commit in the repo-age but this introduces a change that will break for existing cached values. I'm now expecting cached values to be a valid JSON string but they are date strings.
Do we want to handle it for the existing values?

@yakov116
Copy link
Member

yakov116 commented Jan 5, 2020

@hardikmodha looks great. One thing with this change there is a noticeable jump on every load.

@hardikmodha
Copy link
Contributor Author

@yakov116 Yes, I noticed that as well. I'm working on adding some sort of loader icon as we discussed.

@fregante
Copy link
Member

fregante commented Jan 5, 2020

No need to get fancy with loaders. The user timezone feature just uses a static Guessing timezone… placeholder

@fregante
Copy link
Member

fregante commented Jan 5, 2020

Do we want to handle it for the existing values?

I think it’s nicer to handle that now and drop the code later rather than add extra text to our clear key name 😁

@yakov116
Copy link
Member

yakov116 commented Jan 5, 2020

❌ repo-age
content.js:3474 RangeError: Invalid time value
    at repo_age_init (content.js:9396)
    at async features_run (content.js:3469)

@hardikmodha hardikmodha force-pushed the use_first_commit_for_repo_age branch from 7a61131 to e631a12 Compare January 5, 2020 19:59
@hardikmodha
Copy link
Contributor Author

@yakov116 I was not handling the existing cached values previously. Now, I am. Can you check again?

@yakov116
Copy link
Member

yakov116 commented Jan 5, 2020

@hardikmodha nope try
https://github.com/sindresorhus/got
Its crashing on title: First commit dated ${dateFormatter.format(date)}

@hardikmodha
Copy link
Contributor Author

@yakov116 It's working for me. Are you sure on the latest commit?

@yakov116
Copy link
Member

yakov116 commented Jan 5, 2020

Yup

@yakov116
Copy link
Member

yakov116 commented Jan 6, 2020

@hardikmodha I also noticed it will fail on any link that the path has tree in it (open a file from this pr and go to the main page)

@fregante
Copy link
Member

fregante commented Jan 6, 2020

If this is starting to look like a lot of moving parts, you can also split the PR into 2 pieces:

  • use updated data source (the initial intent of the PR)
  • add "loading..."
  • or even a 3rd piece: add link (which means changing the data format) (this was why I marked the suggestion as "Just a thought for now")

@hardikmodha hardikmodha force-pushed the use_first_commit_for_repo_age branch from 40f0850 to 6a399ba Compare January 12, 2020 14:57
@hardikmodha hardikmodha requested a review from fregante January 12, 2020 15:00
return false;
}

if (commitsCount === 1) {
Copy link
Member

Choose a reason for hiding this comment

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

I think repos with a single commit are rare enough that we can drop this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then, What do we display for 1 commit repo?

Copy link
Member

@fregante fregante Jan 14, 2020

Choose a reason for hiding this comment

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

Without this condition, it will just continue like it would with more commits, to fetchDom etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the request would not return anything, the page returned by fetchDom would be empty and we won't find any commits there....

Copy link
Member

Choose a reason for hiding this comment

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

Ouch. Didn’t think it would be. I guess it can stay then.

@fregante
Copy link
Member

Hardik can you split this into multiple PRs as suggested before? #2667 (comment)

The first 2 PRs should be pretty straightforward and can be merged quickly. The 3rd apparently is taking a while to discuss

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

Development

Successfully merging this pull request may close these issues.

repo-age should display the date of the first commit

4 participants