René's URL Explorer Experiment


Title: Reimagine how the app determines its context · Issue #2 · cli/cli · GitHub

Open Graph Title: Reimagine how the app determines its context · Issue #2 · cli/cli

X Title: Reimagine how the app determines its context · Issue #2 · cli/cli

Description: The app currently determines the context it's operating under from several sources: the filesystem (e.g. current directory name) app config file (currently ~/.config/hub in YAML format) environment variables (e.g. GH_REPO, GITHUB_TOKEN, ...

Open Graph Description: The app currently determines the context it's operating under from several sources: the filesystem (e.g. current directory name) app config file (currently ~/.config/hub in YAML format) environment...

X Description: The app currently determines the context it's operating under from several sources: the filesystem (e.g. current directory name) app config file (currently ~/.config/hub in YAML format) environ...

Opengraph URL: https://github.com/cli/cli/issues/2

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reimagine how the app determines its context","articleBody":"The app currently determines the context it's operating under from several sources:\r\n\r\n- the filesystem (e.g. current directory name)\r\n- app config file (currently `~/.config/hub` in YAML format)\r\n- environment variables (e.g. `GH_REPO`, `GITHUB_TOKEN`, etc.)\r\n- git config (via `git config` \u0026 `git remote -v`, sources: `.git/config` \u0026 `~/.gitconfig`)\r\n- git tree (e.g. current branch, current commit SHA)\r\n- SSH config (sources: `~/.ssh/config` \u0026 `/etc/ssh_config`) - resolves SSH aliases for hostnames listed under git remotes\r\n- GitHub API (e.g. info about the current repo)\r\n\r\nWhen something like `gh pr create` gets run, quite a lot happens under the hood. For example:\r\n1. Current GitHub user and OAuth token are obtained from app config;\r\n1. The list of git remotes gets queried and parsed;\r\n2. The \"main\" remote (i.e. one pointing to the canonical GitHub repo) is determined by searching for the first one in this list: `upstream`, `github`, `origin`;\r\n3. The base branch is determined via `git symbolic-ref refs/remotes/\u003cREMOTE\u003e/HEAD` (alternatively, by querying repo information via API);\r\n4. The head branch is determined by looking at the push target for the current branch:\r\n   - explicit upstream branch configuration is first looked up;\r\n   - otherwise, the first remote that has a same-named tracking branch is the likely push target;\r\n   - otherwise, assume the branch isn't pushed yet, so determine the first remote that points to a GitHub project that the current user has write capabilities to;\r\n   - if such a remote doesn't exist, create one by forking;\r\n5. A person's preferred text editor is looked up for authoring PR description text;\r\n6. PR creation operation proceeds.\r\n\r\nTo facilitate all these lookups, the current codebase has a loose system of mapping one piece of information to another. For example:\r\n- current git repo 👉 default (\"base\") branch\r\n- current git repo 👉 \"main\" remote\r\n- git remote 👉 GitHub repository (a.k.a. \"project\") it maps to\r\n- tracking branch 👉 git remote it belongs to\r\n- current user 👉 the person's fork\r\n\r\nSince a lot of lookups start from the current git repo (based on the current working directory at the time that the CLI app runs), there is a LocalRepo struct that encapsulates performing some of these mappings, while additional mapping logic is scattered across individual methods such as `Branch.RemoteName()`, `Remote.Project()`, etc. Some problems I find with the current system:\r\n- Inconsistent naming (e.g. \"repository\" vs. \"project\", the ambiguity of \"branch\")\r\n- Blurred responsibility between objects (e.g. why would a Branch have to know how to map itself to a Remote, or a Remote to a Project?)\r\n- Methods that do too much but don't sufficiently betray intent (e.g. `LocalRepo.RemoteBranchAndProject()`)\r\n- Hard to stub out in tests (ideally, unit tests should be able to set up a mock context in memory rather than having to write a test git repo out to fileystem)\r\n- **All** of this code is under the same Go package: \"github\".\r\n\r\nMy rough proposal for starting to address this:\r\n- [x] Get rid of methods and structs named \"Project\" from the codebase;\r\n- [x] Get rid of LocalRepo;\r\n- [x] Design an abstraction around `git config` that is able to mock responses in memory;\r\n- [x] Consider moving `github/branch.go` to under the \"git\" package;\r\n- [ ] Consider isolating `git/ssh_config.go` to its own package;\r\n- [ ] Minimize the implementation of Remote and instead perform necessary mappings through a separate service object;\r\n- [x] Minimize the \"github\" package until it's ideally gone;\r\n- [ ] Write Go unit tests along the way to confirm the testability of these implementations.\r\n\r\nLet's revise all this as we go along! Thank you for reading. 🙇 ","author":{"url":"https://github.com/mislav","@type":"Person","name":"mislav"},"datePublished":"2019-10-07T17:49:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2/cli/issues/2"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dc164030-8b40-794a-db48-ef7ddffdaeb8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEA98:39E76C:2D0CF92:3D69311:6A545662
html-safe-noncefc8f535cbe0cd58e3da30b47ad42c7bbf8cbb5d6a572a02afa2f11a83ecc763f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTk4OjM5RTc2QzoyRDBDRjkyOjNENjkzMTE6NkE1NDU2NjIiLCJ2aXNpdG9yX2lkIjoiMzc0NTI3MTY5NTA0MjQzNDY1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac02cbb8fd7610c27f71c26f12debe4f0a7bdd79d5ba4a7755b700908ec56ed464
hovercard-subject-tagissue:503598192
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cli/cli/2/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f4d7c3b30e1d1d3a4df6f3ac0a7954464672c6060cae9d7627c8ca5204cab33f/cli/cli/issues/2
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f4d7c3b30e1d1d3a4df6f3ac0a7954464672c6060cae9d7627c8ca5204cab33f/cli/cli/issues/2
og:image:altThe app currently determines the context it's operating under from several sources: the filesystem (e.g. current directory name) app config file (currently ~/.config/hub in YAML format) environment...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemislav
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/cli/cli git https://github.com/cli/cli.git
octolytics-dimension-user_id59704711
octolytics-dimension-user_logincli
octolytics-dimension-repository_id212613049
octolytics-dimension-repository_nwocli/cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id212613049
octolytics-dimension-repository_network_root_nwocli/cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/cli/cli/issues/2#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcli%2Fcli%2Fissues%2F2
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcli%2Fcli%2Fissues%2F2
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=cli%2Fcli
Reloadhttps://github.com/cli/cli/issues/2
Reloadhttps://github.com/cli/cli/issues/2
Reloadhttps://github.com/cli/cli/issues/2
Please reload this pagehttps://github.com/cli/cli/issues/2
cli https://github.com/cli
clihttps://github.com/cli/cli
Notifications https://github.com/login?return_to=%2Fcli%2Fcli
Fork 8.7k https://github.com/login?return_to=%2Fcli%2Fcli
Star 45.3k https://github.com/login?return_to=%2Fcli%2Fcli
Code https://github.com/cli/cli
Issues 967 https://github.com/cli/cli/issues
Pull requests 57 https://github.com/cli/cli/pulls
Discussions https://github.com/cli/cli/discussions
Actions https://github.com/cli/cli/actions
Projects https://github.com/cli/cli/projects
Models https://github.com/cli/cli/models
Security and quality 8 https://github.com/cli/cli/security
Insights https://github.com/cli/cli/pulse
Code https://github.com/cli/cli
Issues https://github.com/cli/cli/issues
Pull requests https://github.com/cli/cli/pulls
Discussions https://github.com/cli/cli/discussions
Actions https://github.com/cli/cli/actions
Projects https://github.com/cli/cli/projects
Models https://github.com/cli/cli/models
Security and quality https://github.com/cli/cli/security
Insights https://github.com/cli/cli/pulse
Reimagine how the app determines its contexthttps://github.com/cli/cli/issues/2#top
https://github.com/mislav
mislavhttps://github.com/mislav
on Oct 7, 2019https://github.com/cli/cli/issues/2#issue-503598192
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.