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

Add commit command #331

Merged
merged 5 commits into from
Jul 5, 2023
Merged

Add commit command #331

merged 5 commits into from
Jul 5, 2023

Conversation

luandy64
Copy link
Contributor

@luandy64 luandy64 commented Jun 29, 2023

Description

This PR adds a repo commit command that implements #330.

QA

  • Installed soft locally
  • Started an instance
  • Pushed a repo
  • Ran the command on a repo

Here's the actual text of the command and its output

soft-serve on  main [!?] via 🐳 desktop-linux via 🐹 v1.20.3 on ☁️  (us-east-1)
✦ ❯ ssh test repo commit soft 191b8320a037dbb30fa36630b785ff4674c16d64 -c
The authenticity of host '[localhost]:23231 ([::1]:23231)' can't be established.
ED25519 key fingerprint is SHA256:ZEXFXEWF/kZa6MVCMvV65jfyc2GyYabkogseZ3WCxGw.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[localhost]:23231' (ED25519) to the list of known hosts.

  diff --git a/go.mod b/go.mod
  index 3bb9f77ba5d9d3ae88ff4dac0a1b1143850d47d2..7abac3f8ff7972a064f0118aed5feba1ccc8bc32 100644
  --- a/go.mod
  +++ b/go.mod
  @@ -19,7 +19,7 @@ require (

   require (
   	github.com/caarlos0/env/v8 v8.0.0
  -	github.com/charmbracelet/keygen v0.4.2
  +	github.com/charmbracelet/keygen v0.4.3
   	github.com/charmbracelet/log v0.2.2
   	github.com/charmbracelet/ssh v0.0.0-20221117183211-483d43d97103
   	github.com/gobwas/glob v0.2.3
  diff --git a/go.sum b/go.sum
  index ae63f72b62d9ff6e9360dd16d4e0bc1de9791e6f..a22804453a8d520351b52a9fdc6d8f3f1c16cce6 100644
  --- a/go.sum
  +++ b/go.sum
  @@ -23,8 +23,8 @@ github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06
   github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
   github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
   github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc=
  -github.com/charmbracelet/keygen v0.4.2 h1:TNHua2MlXc6W1dQB2iW4msSZGKlb8RtxtmYDWUs4iRw=
  -github.com/charmbracelet/keygen v0.4.2/go.mod h1:4e4FT3HSdLU/u83RfJWvzJIaVb8aX4MxtDlfXwpDJaI=
  +github.com/charmbracelet/keygen v0.4.3 h1:ywOZRwkDlpmkawl0BgLTxaYWDSqp6Y4nfVVmgyyO1Mg=
  +github.com/charmbracelet/keygen v0.4.3/go.mod h1:4e4FT3HSdLU/u83RfJWvzJIaVb8aX4MxtDlfXwpDJaI=
   github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
   github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
   github.com/charmbracelet/log v0.2.2 h1:CaXgos+ikGn5tcws5Cw3paQuk9e/8bIwuYGhnkqQFjo=

Screeenshots

With color
CleanShot 2023-06-29 at 18 24 56@2x

Colorless
CleanShot 2023-06-29 at 18 54 40@2x

Copy link
Member

@aymanbagabas aymanbagabas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luandy64 Thanks for the PR, looks good! I think it would be better to match the output of Soft Serve UI commit view to show the commit hash, author, date, stats, and patch. It would also be nice to have a -p option to only show the patch for the commit.

image

commit 814ee9f8fa7014dd4fafab12974e2edd4b8f7d73
Author: Andy Lu <luandy64@gmail.com>
Date:   Fri Jun 30 23:07:49 2023 -0400

    Run gofmt

commit 3db029502c74461b57e776a0ebc9d27c944acc5d
Author: Andy Lu <luandy64@gmail.com>
Date:   Fri Jun 30 23:06:31 2023 -0400

    Pull out statsLine and diffLine, add a commit body line

commit eb1da4296e0181bae842622e0dc98ca8ca845049
Author: Andy Lu <luandy64@gmail.com>
Date:   Fri Jun 30 23:05:36 2023 -0400

    Add flag for printing the patch only

commit e76702e92b085f02427aae1c7052f235454242fd
Author: Andy Lu <luandy64@gmail.com>
Date:   Fri Jun 30 22:50:55 2023 -0400

    Add commit, author, date, and stats

commit 0359b1dc49417d11f8f8b8529f8b942417d79128
Author: Andy Lu <luandy64@gmail.com>
Date:   Fri Jun 30 21:43:35 2023 -0400

    Add commit, author, date, and stats

    Missing color on stats
@luandy64
Copy link
Contributor Author

luandy64 commented Jul 1, 2023

Screenshots to go with the last commit (65d308e)

No flags:
CleanShot 2023-07-01 at 03 11 35@2x

Use -c:
CleanShot 2023-07-01 at 03 23 52@2x

Use -p:
CleanShot 2023-07-01 at 03 26 41@2x

Use both -cp:
CleanShot 2023-07-01 at 03 27 42@2x

@luandy64
Copy link
Contributor Author

luandy64 commented Jul 1, 2023

Actually, I noticed a whitespace difference in that other commit. So here's one where I compared with the TUI

Top of the output:
CleanShot 2023-07-01 at 03 38 53@2x

Bottom of the output:
CleanShot 2023-07-01 at 03 42 34@2x

@codecov
Copy link

codecov bot commented Jul 1, 2023

Codecov Report

Merging #331 (64920c3) into main (191b832) will decrease coverage by 0.59%.
The diff coverage is 10.93%.

@@            Coverage Diff             @@
##             main     #331      +/-   ##
==========================================
- Coverage   47.82%   47.23%   -0.59%     
==========================================
  Files          80       81       +1     
  Lines        7254     7382     +128     
==========================================
+ Hits         3469     3487      +18     
- Misses       3512     3622     +110     
  Partials      273      273              
Impacted Files Coverage Δ
server/cmd/commit.go 10.23% <10.23%> (ø)
server/cmd/repo.go 87.32% <100.00%> (+0.18%) ⬆️

... and 1 file with indirect coverage changes

@aymanbagabas aymanbagabas merged commit b60a7f2 into charmbracelet:main Jul 5, 2023
aymanbagabas added a commit that referenced this pull request Jul 13, 2023
aymanbagabas added a commit that referenced this pull request Jul 13, 2023
aymanbagabas added a commit that referenced this pull request Jul 17, 2023
* refactor(server): abstract database from backend

Prepare for multi database driver support

* feat(server): add db models

* feat(db): add database migrations

* feat(db): add support to postgres

* feat: implement database store logic

* refactor: use db module and abstract backend logic

* fix(db): postgres migrate sql

* feat(db): add database query tracing

* refactor: move internal packages to server

* fix(config): normalize sqlite database path

* fix,feat: support custom log path and fix logging leak in hooks

* fix(test): race condition

* refactor: tidy up files and use middlewares

* chore: add test for repo commit command

Reference: #331

* fix: lint errors

* fix: use utc time and fix git packp error format

* fix: lint errors

* fix: testscript on windows

* chore: format sql files

* fix: lint issues

re-enable revive linter

* refactor: clean up server/config

* feat: add admin command to manage server

* fix(db): use migration versions

* chore: add deprecation warning.

* refactor: move shared interfaces and errors to proto

* fix: increase golangci lint timeout

* feat: add move tests
@aymanbagabas aymanbagabas linked an issue Jul 19, 2023 that may be closed by this pull request
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.

feat: Show diff for a particular commit
2 participants