Hacker News new | ask | show | jobs
by saleemkce 1666 days ago
I think they have stars counter table which they refresh or reset when a repo goes from public to private. But, the real question is, why not Github alert you by saying that the switch will make you lose all your hard-earned stars?
5 comments

They 100% do alert you. This is an unfortunate situation, but all of these things are presented to you before you make the switch.
>why not Github alert you by saying that the switch will make you lose all your hard-earned stars?

It is the first bullet point when you are submitting acknowledgement that you want to switch your repo to private.

Thanks for informing this. I just came to know this first time.
I'm assuming that they have a relation user <-> repo of repos that the user has starred. If the user in question doesn't have access to the repo, the entry should be deleted.
I was thinking the same thing. The star count is not just a number in their database. It is a count based on the underlying user data.

If Github deleted the user-to-starred-repo data then it'd be awfully difficult to restore the previous stars. They'd have to know which users had starred the repo previously and restore each of those relations.

Do they have backup data? Probably, but that's in the case of an emergency, not because of something like this.

In the modal for changing the visibility of a repo, when switching it from public to private, it says:

> You will permanently lose: All stars and watchers of this repository.

---

When the repository goes private, GitHub doesn't retain stars because they would be invalid; you can't star a repo you can't see, so those records would be meaningless. It could store them and "replace" them should the repo go public again, but then the repo could be very different from what the user starred in the first place.

Since they keep track of who starred what, that means each star is a row. Does that mean they actually delete these rows? Why not just keep the rows, perhaps with a flag or join to filter the repo out of the API.
your point is quite informative!