Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git client part 2: HTTP #418

Merged
merged 34 commits into from
Jun 28, 2024
Merged

Conversation

AtkinsSJ
Copy link
Collaborator

@AtkinsSJ AtkinsSJ commented May 22, 2024

Initially this was just about HTTP but it's ended up being many things. Enjoy!

New commands:

  • git clone
  • git remote
  • git branch
  • git fetch
  • git pull
  • git push
  • git checkout
  • git diff
  • git restore
  • git cherry-pick

Other noteworthy features:

  • Coloured output
  • Diff display
  • Ref names show up when looking at commits
  • Bug fixes

@AtkinsSJ AtkinsSJ mentioned this pull request May 22, 2024
@AtkinsSJ AtkinsSJ force-pushed the git-client-http branch 4 times, most recently from f991278 to c8c9901 Compare June 4, 2024 15:43
@AtkinsSJ
Copy link
Collaborator Author

AtkinsSJ commented Jun 4, 2024

git checkout <from> -- <pathspec>... is... interesting. I have a stash where I added the functionality, which isogit actually does for you as part of their git.checkout() function... except it just does a bunch of processing, after which the files haven't changed. So I might be missing something.

@AtkinsSJ AtkinsSJ force-pushed the git-client-http branch 5 times, most recently from 29845e2 to b48f3ca Compare June 11, 2024 15:34
@AtkinsSJ AtkinsSJ force-pushed the git-client-http branch 7 times, most recently from f64f482 to 6abae0a Compare June 24, 2024 16:49
@AtkinsSJ AtkinsSJ marked this pull request as ready for review June 26, 2024 16:44
@AtkinsSJ
Copy link
Collaborator Author

Marking this as ready, so people have a chance to ask for changes! 😅

There's more I'd like to do, particularly making commit references like HEAD~2, or master^1, work, but that doesn't have to delay this PR. I'll just add that if this isn't merged, or submit another PR with it. :^)

git is far more pleasant to use with the changes in #498, too.

@jelveh
Copy link
Contributor

jelveh commented Jun 26, 2024

Can't wait to merge this 💙

@AtkinsSJ
Copy link
Collaborator Author

Parsing foo^ and HEAD~3 turned out to be relatively straightforward, so that's added here. :^)

Create, delete, copy, rename, and list branches.
Sporadically we hang while trying to fetch. I haven't been able to
identify why but it seems like a race condition in isomorphic-git
somewhere.
This is functionally the same, but removes one place where we
unnecessarily relied on Puter code.
We'll likely want to host our own proxy. Self-hosters likewise may have
their own, but it's convenient to use isomorphic-git's for development.
For now, the authentication is by --username and --password options,
which obviously is not good because the password is visible. But doing
it in a nicer way requires features that Phoenix or Puter are currently
missing.
These allow the user to force color on or off. The chalk library is used
for the output, because it's already used elsewhere in Puter and seems
like a good choice.

Ideally, the default will be based on whether stdout is a tty, but Puter
doesn't yet have that concept, so we just default to color.
Previously, this:

```sh
> rm deleted.txt
> git add deleted.txt
```

...would unhelpfully complain that deleted.txt cannot be found. Now, it
records the deleted file to the index, just as canonical git does.
Make some parts colored or bold, and indent commit messages.
Specifically, we previously didn't resolve short commit hashes into the
full ones.

These functions provide a single place to later add more ways of
selection a commit, such as `HEAD~1`.
I tried implementing --source=foo too, but was bumping into weird
behaviour with isomorphic-git, so I've removed that for now. Eventually
we'll want it, but it seems fairly niche.
Matching canonical git, staged changes are green and unstaged/untracked
are red.
This is quite manual, and only handles the simple cases where no merge
conflicts occur. Should be useful for basing a `rebase` command off of
though.
I ended up removing the debugging code that used this, but it seems
useful anyway for future debug logs.
Until now we just relied on it being very unlikely that there would be a
collision. This new method ensures that the returned hash is unique.
Parsely was missed by fa7bec3 because
it got merged afterwards.
There are a lot of ways of specifying a revision, but these are a couple
of common ones.
@KernelDeimos KernelDeimos merged commit d077504 into HeyPuter:main Jun 28, 2024
5 checks passed
@AtkinsSJ AtkinsSJ deleted the git-client-http branch June 28, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants