github-url-detection icon indicating copy to clipboard operation
github-url-detection copied to clipboard

Migrate `getCurrentCommittish` and `GitHubURL` here?

Open kidonng opened this issue 3 years ago • 8 comments

Another GitHub-related browser extension Gitako encountered the infamous "slash-in-branch-name" issue: https://github.com/EnixCoda/Gitako/issues/243

Refined GitHub had similar experience and that (along with other issues) resulted in the GitHubURL helper (and its dependency getCurrentCommittish). I think these helpers are generally useful for others as well, so is there any interest maintaining them here?

Issue with this approach is that the helpers are huge comparing to the existing getRepo helper. And it's not super related to URL detection, so it probably should be its own thing.

kidonng avatar Jul 27 '22 13:07 kidonng

I think we can extract it to be its own module, I like how simple this one is no need to complicated it.

@refined-github/maintainers thoughts?

yakov116 avatar Jul 27 '22 13:07 yakov116

To be fair, I think most github-helpers are useful on their own[^1], like get-user-avatar. But let's not overcomplicate things 😅 this issue only considers branch name related stuff.

[^1]: maybe one day I extract them to modules myself, that's MIT for you

kidonng avatar Jul 27 '22 13:07 kidonng

maybe one day I extract them to modules myself, that's MIT for you ↩

Well be glad to host them. That's refined-github for you 🤪

yakov116 avatar Jul 27 '22 13:07 yakov116

Link: https://github.com/refined-github/refined-github/blob/3547c9bc0e60443dafe06752bc94e9e5b73f8d55/source/github-helpers/index.ts#L37

Things I'm not excited about:

  • how transient and imperfect each of those API is
  • documenting them and releasing breaking versions more often than this module requires
  • external contributions (or lack thereof)
  • the slowing of RG’s development due to having them externally and having to consider third parties
  • having to also extract every internal function that those helpers use, further slowing RG’s development

I wouldn't be totally opposed to publishing a "gh extensions utils" package but I'd probably suggest using npm install refined-github/refined-github in order to access those files directly instead.

fregante avatar Jul 27 '22 14:07 fregante

I'll add, even if we go to the trouble of doing all of that, it doesn't mean it actually helps that many people. See how many repos use this very simple, very old package:

https://github.com/refined-github/github-url-detection/network/dependents

Here's the total of 2 non-fork non-ghosttown extensions that use it:

  • https://github.com/ineo6/git-master/search?q=github-url-detection
  • https://github.com/hypertrons/hypertrons-crx/search?q=github-url-detection

I'd argue we didn't even need to extract github-url-detection. 😃 The only reason it's still great to have is that it makes it easier to test it and work on it.

fregante avatar Jul 27 '22 14:07 fregante

The only reason it's still great to have is that it makes it easier to test it and work on it.

Exactly why we extracted, the tests took too much time.

yakov116 avatar Jul 27 '22 14:07 yakov116

@fregante Really good points. I agree it's too much hassle for those simple helpers, I brought up about this one because I think it's an exception:

  • There are projects that could benefit from it
  • It (mostly) fits in this package
  • More people using it, more/faster bugs are found

kidonng avatar Jul 27 '22 14:07 kidonng

PR welcome to add those two:

  • utils/github-url.ts
  • utils/get-current-committish.ts

fregante avatar Feb 04 '23 12:02 fregante