Commit Graph

43 Commits

Author SHA1 Message Date
Sam Atkins
d077504f9b doc(git): Expand documentation and add FIXMEs 2024-06-28 14:19:23 -04:00
Sam Atkins
711dbc0d2f feat(git): Understand references like HEAD^ and main~3
There are a lot of ways of specifying a revision, but these are a couple
of common ones.
2024-06-28 14:19:23 -04:00
Sam Atkins
45cdfcb5bf feat(git): Display ref names in git log and git show 2024-06-28 14:19:23 -04:00
Sam Atkins
351d3f50ba tweak(git): List git subcommands in git help with no arguments 2024-06-28 14:19:23 -04:00
Sam Atkins
73d0f5a90c fix(git): Make git commit display detached HEAD correctly 2024-06-28 14:19:23 -04:00
Sam Atkins
dd10a37749 feat(git): Make shorten_hash() guaranteed to produce a unique hash
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
fa3df72f6e feat(git): Add a --debug option, which sets the DEBUG global
I ended up removing the debugging code that used this, but it seems
useful anyway for future debug logs.
2024-06-28 14:19:23 -04:00
Sam Atkins
2e4259d267 feat(git): Implement git cherry-pick
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
bab5204209 feat(git): Color output for git status files
Matching canonical git, staged changes are green and unstaged/untracked
are red.
2024-06-28 14:19:23 -04:00
Sam Atkins
4ba8a32b45 feat(git): Implement git restore
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
a68037111a feat(git): Display file contents as a string for git show FILE_OID 2024-06-28 14:19:23 -04:00
Sam Atkins
b6906bbcaa feat(git): Resolve more forms of commit reference
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`.
2024-06-28 14:19:23 -04:00
Sam Atkins
60976b1ed6 feat(git): Format output closer to canonical git
Make some parts colored or bold, and indent commit messages.
2024-06-28 14:19:23 -04:00
Sam Atkins
955154468f feat(git): Make git add work for deleted files
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
057b3acf00 feat(git): Allow checking out a commit instead of a branch 2024-06-28 14:19:23 -04:00
Sam Atkins
2c9b1a3ffc feat(git): Handle detached HEAD in git status and git branch --list 2024-06-28 14:19:23 -04:00
Sam Atkins
d6dd1a5bb0 feat(git): Add --color and --no-color options
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
364d580ff8 feat(git): Add authentication to clone, fetch, and pull. 2024-06-28 14:19:23 -04:00
Sam Atkins
8c70229a18 feat(git): Implement git push
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
3cad1ec436 feat(git): Add diff display to show and log subcommands 2024-06-28 14:19:23 -04:00
Sam Atkins
c436460b8c tweak(git): Move proxy url definition into config files
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
a68194090e tweak(git): Check for 'ENOENT' instead of ErrorCodes.ENOENT
This is functionally the same, but removes one place where we
unnecessarily relied on Puter code.
2024-06-28 14:19:23 -04:00
Sam Atkins
622b6a9b92 feat(git): Implement git diff 2024-06-28 14:19:23 -04:00
Sam Atkins
49c2f16351 feat(git): Add start-revision and file arguments to git log 2024-06-28 14:19:23 -04:00
Sam Atkins
eb2b6a08b0 feat(git): Implement git pull 2024-06-28 14:19:23 -04:00
Sam Atkins
1822ace296 refactor(git): Use dir/gitdir variable names like isogit does
I prefer the other names, but being able to type `{ dir, gitdir }` is
shorter and a lot less error-prone than `{ dir: repository_dir, gitdir:
git_dir }`.
2024-06-28 14:19:23 -04:00
Sam Atkins
35e4453930 feat(git): Implement git checkout
For now this only lets you check out branches, not files.
2024-06-28 14:19:23 -04:00
Sam Atkins
98a4b9ede3 feat(git): Implement git fetch
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.
2024-06-28 14:19:23 -04:00
Sam Atkins
c86e4dfdce Remove unused imports from git subcommands 2024-06-28 14:19:23 -04:00
Sam Atkins
ad4f13255d feat(git): Implement git branch
Create, delete, copy, rename, and list branches.
2024-06-28 14:19:23 -04:00
Sam Atkins
43ce0d5b45 feat(git): Implement git remote 2024-06-28 14:19:23 -04:00
Sam Atkins
95c8235a4a feat(git): Implement git clone 2024-06-28 14:19:23 -04:00
Sam Atkins
10f715f726 Implement git show 2024-05-22 16:00:42 +01:00
Sam Atkins
0377015190 Implement git config
This is also basic:

git config key             # To read a value
git config key value       # To set a value
git config --unset key     # To delete a value

As noted, --list is not possible to implement currently.
2024-05-22 16:00:42 +01:00
Sam Atkins
98c33fb3cc Implement git log
This is quite barebones for now.

Commit formatting is done in a separate file, as this is used by other
git commands, such as `show`.
2024-05-22 16:00:42 +01:00
Sam Atkins
b4e2ba4544 Implement git commit 2024-05-22 16:00:42 +01:00
Sam Atkins
32c172d145 Implement git add 2024-05-22 16:00:42 +01:00
Sam Atkins
5a308a2a53 Implement git status 2024-05-22 16:00:42 +01:00
Sam Atkins
71873a9c27 Add a helper function for finding the git repo 2024-05-22 16:00:42 +01:00
Sam Atkins
5e3db870ec Implement git init 2024-05-22 16:00:42 +01:00
Sam Atkins
85b7587c42 Implement git help, git version, and subcommand infrastructure
Each subcommand is its own file, modeled after Phoenix's coreutils.
2024-05-22 16:00:42 +01:00
Sam Atkins
b75c42b39f Implement Puter filesystem wrapper for git app 2024-05-22 08:56:50 +01:00
Sam Atkins
0d2ffdb380 Add boilerplate for empty git app
It does nothing but output a message to the console.
2024-05-22 08:56:50 +01:00