René's URL Explorer Experiment


Title: Improve scripts and tool configurations by EliahKagan · Pull Request #1693 · gitpython-developers/GitPython · GitHub

Open Graph Title: Improve scripts and tool configurations by EliahKagan · Pull Request #1693 · gitpython-developers/GitPython

X Title: Improve scripts and tool configurations by EliahKagan · Pull Request #1693 · gitpython-developers/GitPython

Description: Fixes #1690 Fixes #1691 Fixes #1692 This combines the solutions I recommended in those three issues on a single branch. Although I feel this does compose into a coherent whole, with each of those issues' practical ramifications having some tendrils into each other, and opening separate PRs would have resulted in nontrivial merge conflicts... nonetheless this PR is broader than I would usually like. But I have done it this way because it was by working on them together that I was able to get clear on the distinct ideas that I presented as those issues, as well as whether the solutions would work reasonably when all combined. This PR is what remains after pieces that seemed reasonable to sever into their on PRs, such as #1684, have been removed, and excessively enterprising ideas, such as writing a batch-file version of init-tests-after-clone.sh (discussed in #1691) or switching lint.yml to use pre-commit.ci, abandoned or deferred. However, I would be pleased to make further changes as requested. I think the changes here are feasible to review together, but I am willing to rework this into multiple more narrowly scoped PRs if necessary. The problems and their solutions in general are presented in the three linked issues that this would close. (Details are given in commit messages.) Specific considerations that I suspect may be important when reviewing this PR follow. Shell script portability I believe the shell scripts that pertain to building do not need to be any more portable than they are now: they run on bash version 3 or later, which most systems have or can get. I did make modifications to them, some of which were inspired and emboldened by shellcheck, but not for portability to other shells. I take #1661 (comment) (specifically: d18d90a, 1e0b3f9) as an indication of a general preference of echo over printf. The bash shell provides an echo builtin that has good design decisions and, more importantly, behaves the same in bash on any system, because it is a builtin. (I have actually slightly increased the use of echo in bash in this PR.) However, for POSIX shell scripts that assume only what the standard insists on (or that call echo through another command, such as with find -exec or xargs, thereby using an external echo executable), the situation is considerably messier. To write a portable script, I have avoided the use of echo in the init script that, for portability, I have changed from bash to sh. What fallback version-tag fetching looks like Fallback fetching of version tags is the "back-up" strategy that is part of the fix for #1690. It works both locally and on CI. Here's what it looks like on CI (I temporarily deleted all the version tags from my fork and reran the tip of this PR's branch): Ubuntu Cygwin (In case for any reason you want to see the version from an earlier commit and prior to multiple rebases that I had shown before in an earlier draft of this PR description, that's here.) Fallback version-tag fetching would fail on old git At least as currently written, it uses a feature that was introduced in Git 2.6.0. I have posted a review comment on the specific code this affects, with full details. Security implications of where init-tests-after-clone.sh makes master Edit: Based on #1615, I think you might prefer git checkout -B master not be used, for reasons of stability rather than security. Maybe git checkout -B master ea43defd777a9c0751fc44a9c6a622fc2dbd18a0 should even be used, to get the same old commit even in forks that don't have the master branch, and to add the same commits to the top of the reflog history even when __testing_point__ is deleted and the script rerun. Currently, on main, init-tests-after-clone.sh creates or switches to a master branch like this: git checkout master || git checkout -b master One of the changes in this PR is to ensure that master cannot be interpreted as a path--it has to be taken to be a branch, or at least a ref--which is mainly for better output to stderr when the branch doesn't exist, but also to safeguard against rare situations where a file or directory named master exists: git checkout master -- || git checkout -b master However, there is a simpler, more elegant, and more robust way to get a suitable master branch for tests, that I think is more likely to work well most of the time [edit: though the answer to #1615 suggests a reason it might not]: git checkout -B master master is already getting reset back to __testing_point__, so the main disadvantage of -B, that one can lose one's branch if it is not pushed, applies already. I would like to do it that way (and I have a branch for it, ready to go). But it has security implications, specifically for people who review pull requests. As detailed in #1690, wherever master gets checked out, editors and IDEs may be fooled into running unreviewed untrusted code from there. Using the -B way I want to use would be a mitigation for the situation described in #1690 (though that's not the main reason I want to do it). But it would be an exacerbation of it for a reviewer, because it would weaken the already brittle assurance git diff main feature would provide. Consider: main ← evil ← evil ← evil ← feature There, a pull request proposes a useful feature on the feature branch. But the preceding three commits have evil code in them that, if an editor/IDE imports modules to do test discovery (or any other operation the editor reserves for "trusted folders"), will be run. The tip of feature removes the evil code, so git diff main feature does not reveal it. But because master is checked out at the tip of feature even if master already exists in the reviewer's local or remote repository, the script's reflog-building commands reset to each of the evil commits. This may not be a serious problem. When reviewing, one should already not rely merely on git diff main feature, and CI in pull requests is set up to run on the pull-request trigger (which, unlike pull-request-target which is dangerous if not used very carefully, runs with the fork's permissions, not allowing elevation). Furthermore, one may already not have master locally or on a remote, in which case the existing checkout code already creates it at HEAD, so it's not like this is a new situation. Furthermore, it's generally unnecessary to run that script while reviewing, even if one opens up an only partially reviewed PR branch in an editor that may perform unsafe operations based on its contents. Nonetheless, I wanted to bring this up rather than just adding a commit to change it to git checkout -B master. black via pre-commit: I'm not sure what's best. It seems to me that there is actually just one thing that, in hindsight, would have been better to have developed separately. Adding black to pre-commit, and using that on CI, presents choices to be made while reviewing that are practically separate from the other changes. The core issue is that all the other tools run via pre-commit only perform checks, while the way most users of black and pre-commit would expect and prefer they be used together is for pre-commit to actually perform auto-formatting. This is actually no problem on CI; the GitHub Action being used accepts code changes from a hook as a check failure. But there should be a way to just lint locally, that includes checking for black-conforming formatting and that does not change any files. Therefore, I have set up two hooks for black: one that runs by default and formats, and another that does not run by default and that only performs checks. The tox linting environment and lint.yml CI workflow use the check-only hook and skip the formatting one. But there should also be a way to do this locally without building the project and setting up tox environments and without typing in a complex pre-commit command. So I have made make lint do that. This is all documented as part of the readme improvements. It is inelegant, though, because everything else done by makefiles in this project is directly related to building. There are a few options, which I present in descending order of my preference, but they are all things I think are reasonable: Use this, for now. Use this, for now, but add a note in the readme about how make lint may go away. (I think this is not really necessary, because the development instructions are not implied to be stable. But I am not sure.) Change pre-commit to have only the check-only black hook, at least for now, and modify the readme accordingly. Then there is no need for make lint because pre-commit run --all-files just lints, as it did before, but including black. This has the disadvantage that people who like black and pre-commit probably prefer that they facilitate auto-formatting, but it is otherwise elegant. I suspect you might prefer this approach, therefore I have made a commit for it on my sh-nofmt branch, which can be easily fast-forward merged into here (or opened as a separate PR if the change is desired after merging this). Remove everything to do with black from .pre-commit-config.yml on this branch, modifying the readme accordingly, and propose it separately. It could be removed by rebasing, or just by adding a commit to remove it. This is more work, but actually a bigger reason this is not my preferred approach is the same reason I had added black to pre-commit in the first place: with everything else being done by pre-commit, and with this project being in black style (aside from this project's very long lines), it is unintuitive and unexpected that it would not, in any form, be usable via pre-commit.

Open Graph Description: Fixes #1690 Fixes #1691 Fixes #1692 This combines the solutions I recommended in those three issues on a single branch. Although I feel this does compose into a coherent whole, with each of those i...

X Description: Fixes #1690 Fixes #1691 Fixes #1692 This combines the solutions I recommended in those three issues on a single branch. Although I feel this does compose into a coherent whole, with each of those i...

Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/1693

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:7fa94c74-02ae-1256-780f-b4ea3c036a04
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idE85E:C7A41:1337601:1ACA77C:6968AFA3
html-safe-noncea9633dbcdc4999514aea3434747166d0e36bf89a51fd8e8eb15a98244e97ee87
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODVFOkM3QTQxOjEzMzc2MDE6MUFDQTc3Qzo2OTY4QUZBMyIsInZpc2l0b3JfaWQiOiI2MzYwNTA1MTc2MTEwMzI0ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfc3d0c6b600f4dbf2212d62860a37e91fc2d9216185c3df2c489c5cb86b2c216
hovercard-subject-tagpull_request:1540997533
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/1693/checks
twitter:imagehttps://avatars.githubusercontent.com/u/1771172?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1771172?s=400&v=4
og:image:altFixes #1690 Fixes #1691 Fixes #1692 This combines the solutions I recommended in those three issues on a single branch. Although I feel this does compose into a coherent whole, with each of those i...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonefdc7c66bd36a6c12eb8e771e806db863266e573fc299e77f27505a768d4f8a98
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3223a6503d318917691422cdadfbe16cd8fb21e5
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/pull/1693/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fpull%2F1693%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2Fgitpython-developers%2FGitPython%2Fpull%2F1693%2Fchecks
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%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/pull/1693/checks
Reloadhttps://github.com/gitpython-developers/GitPython/pull/1693/checks
Reloadhttps://github.com/gitpython-developers/GitPython/pull/1693/checks
gitpython-developers https://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/1693/checks
Notifications https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Fork 964 https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Star 5k https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Code https://github.com/gitpython-developers/GitPython
Issues 169 https://github.com/gitpython-developers/GitPython/issues
Pull requests 8 https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/gitpython-developers/GitPython/security
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/1693/checks
Insights https://github.com/gitpython-developers/GitPython/pulse
Code https://github.com/gitpython-developers/GitPython
Issues https://github.com/gitpython-developers/GitPython/issues
Pull requests https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security https://github.com/gitpython-developers/GitPython/security
Insights https://github.com/gitpython-developers/GitPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
Byronhttps://github.com/Byron
gitpython-developers:mainhttps://github.com/gitpython-developers/GitPython/tree/main
EliahKagan:shhttps://github.com/EliahKagan/GitPython/tree/sh
Conversation 16 https://github.com/gitpython-developers/GitPython/pull/1693
Commits 32 https://github.com/gitpython-developers/GitPython/pull/1693/commits
Checks 0 https://github.com/gitpython-developers/GitPython/pull/1693/checks
Files changed 13 https://github.com/gitpython-developers/GitPython/pull/1693/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/1693/checks
Improve scripts and tool configurations https://github.com/gitpython-developers/GitPython/pull/1693/checks#top
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/1693/checks
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.