Comments (6)
Yes its possible. After some digging into the Github API I found where to query for a "default_branch".
V3 Rest API:
https://developer.github.com/v3/repos/#get-a-repository
V4 GraphQL API
query DefaultBranchQuery {
repository(owner: "bridgetownrb", name: "bridgetown"){
defaultBranchRef {
name
}
}
}
will return the following data:
{
"data": {
"repository": {
"defaultBranchRef": {
"name": "main"
}
}
}
}
from bridgetown.
@ParamagicDev Cool! As I think about this, I've run into rate limits in the past using the GH API without a specific key, but that was when pinging the API multiple times a minute from the same machine. So I'm guessing a one-off now and then should be fine, but we'll want to gracefully handle any error conditions.
from bridgetown.
https://developer.github.com/v3/#rate-limiting You are correct. An unauthenticated user is allowed 60 requests / hour under the REST API. And a similar number under the graphQL api.
There is another way to check the default branch using the git
cli, but it would require cloning the repository.
I guess we could silently pull down the repository into a tempdir
, check the default branch, then request the automation. Although at that point, you could just run the automation directly in the cloned repo....
Edit: the more I think about it, the more I like the idea of pulling a repo down in the background because if a user requests a different branch, you could simply do git checkout
otherwise, you're already on the default branch.
from bridgetown.
Hmm 🤔
I know we're already manually doing Git checkouts in some of the automations…but that feels a little heavyweight to me to go with for a default approach.
from bridgetown.
Maybe if no master branch is found, raise an error and prompt the user to provide a branch?
EDIT: Actually, if no master branch is found, we could rescue the error and then we could prompt the user to provide a branch on the command line so they don't have to retype the command.
from bridgetown.
At the risk of overcomplicating things, I suggest we could try the following:
- Use the GitHub API to get the default branch name
- In the event that API call fails, hardcode master and try that
- If that doesn't work, then we could ask for the branch name
Honestly I'm fine even with dropping option 3… just prompt them to paste a branch-specific URL instead.
from bridgetown.
Related Issues (20)
- The `paginate` front matter variable is ignored by prototype pages
- feat: Allow pages without front matter to be processed HOT 1
- Pages which `paginate` are excluded from `collections.pages` HOT 3
- Unable to access frontmatter array HOT 3
- feat: Folder inversion — source files in root folder, Bridgetown support files in subfolder HOT 8
- docs: How to setup GitHub Pages + Bridgetown HOT 1
- Netlify bundled configuration issues HOT 3
- environment condition not working when checked in liquid template HOT 2
- docs: Bundling images HOT 1
- docs: /docs/installation/windows
- esbuild can't import scss files from node_modules HOT 1
- LogWriter not compatible with the Ruby 3.3 implementation of Logger HOT 1
- feat: `_html` translation key automatic safety support HOT 1
- docs: show how to read collections in SSR mode HOT 1
- NameError when using bridgetown-activerecord with Roda HOT 6
- Issue with Resource API following #778 HOT 1
- docs: use symbolic link for `bt` binstub HOT 3
- Remove hard dependency on Puma and add generic Rack compliance
- Refactor live reloads to use Rack 3 streaming bodies HOT 2
- feat: make PostCSS optional…possibly off by default HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bridgetown.