sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Add a button to jump to first and latest commit #3455

Androz2091 posted onGitHub

Hey! I'm the one who opened the issue to add the repo-age feature, because I think it's really interesting to know how a project was... in the beginning, and what was done first. Sometimes I spend a lot of time spamming the "Older" button to see what the first commits were. So if we could add these buttons it would be really really useful: Capture d’écran 2020-08-12 à 17 30 19 (or first page/last page, some websites use this term)

It would be very easy to make them, as we could just get the first commit hash, the number of commits and then generate an URL like https://github.com/Androz2091/AtlantaBot/commits/master?after=FIRSTCOMMITHASH+NUMBEROFCOMMITS&branch=master.


I've had this use-case before too, but I don't think it's common enough to be with the other navigation buttons. It could just be a small "Last page" link somewhere.

posted by sindresorhus over 4 years ago

Newest

It's already possible:

Oldest

It's already possible to get the very first commit thanks to repo-age (https://github.com/sindresorhus/refined-github/pull/3169), but there's no way to see the History page once there.

posted by fregante over 4 years ago

I've had this use-case before too, but I don't think it's common enough to be with the other navigation buttons. It could just be a small "Last page" link somewhere.

Yes, I agree, a small link to jump to the last page would be better than a button the same size as the main buttons.

It's already possible to get the very first commit thanks to repo-age (#3169), but there's no way to see the History page once there.

Yes, I saw that, and that's why a link might be useful. And for me, a link to the "oldest page" is more interesting than a link to the "newest page", because we are on the newest page by default.

posted by Androz2091 over 4 years ago

If we extract this part of the function, this feature would come for free since the commitCount would already be cached:

https://github.com/sindresorhus/refined-github/blob/6bba1c5de1e8b609e010f252d72ff9c63af431a6/source/features/repo-age.tsx#L46-L63

Probably:

export const getLatestCommitInfo = cache.function(async () => {
    const {repository} = await api.v4(`
        repository(${getRepoGQL()}) {
            defaultBranchRef {
                target {
                    ... on Commit {
                        hash: oid
                        date: committedDate
                        path: resourcePath
                        commitCount: history {
                            totalCount
                        }
                    }
                }
            }
        }
    `);

    const {target} = repository.defaultBranchRef;
    target.commitCount = target.commitCount.totalCount;
    return target;
}, {
    cacheKey: () => 'latest-commit-info:' + getRepoURL()
});
posted by fregante over 4 years ago
posted by yakov116 over 4 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests