-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[supervisor] Don't install git msg annotation hook in headless workspaces #20548
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
Changes from 3 commits
71916c7
087c38e
a9290d7
0712aea
c0de48f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,16 @@ func Run(options ...RunOption) { | |
| return | ||
| } | ||
|
|
||
| var ( | ||
| ideReady = newIDEReadyState(&cfg.IDE) | ||
| desktopIdeReady *ideReadyState = nil | ||
|
|
||
| cstate = NewInMemoryContentState(cfg.RepoRoot) | ||
| gitpodService serverapi.APIInterface | ||
|
|
||
| notificationService = NewNotificationService() | ||
| ) | ||
|
|
||
| endpoint, host, err := cfg.GitpodAPIEndpoint() | ||
| if err != nil { | ||
| log.WithError(err).Fatal("cannot find Gitpod API endpoint") | ||
|
|
@@ -211,6 +221,14 @@ func Run(options ...RunOption) { | |
| symlinkBinaries(cfg) | ||
|
|
||
| configureGit(cfg) | ||
| go func() { | ||
| <-cstate.ContentReady() | ||
| if cfg.CommitAnnotationEnabled && !cfg.isHeadless() { | ||
| if err := setupGitMessageHook(filepath.Join(cfg.RepoRoot, ".git", "hooks")); err != nil { | ||
| log.WithError(err).Error("cannot setup git message hook") | ||
| } | ||
| } | ||
| }() | ||
|
|
||
| telemetry := analytics.NewFromEnvironment() | ||
| defer telemetry.Close() | ||
|
|
@@ -260,16 +278,6 @@ func Run(options ...RunOption) { | |
| internalPorts = append(internalPorts, debugProxyPort) | ||
| } | ||
|
|
||
| var ( | ||
| ideReady = newIDEReadyState(&cfg.IDE) | ||
| desktopIdeReady *ideReadyState = nil | ||
|
|
||
| cstate = NewInMemoryContentState(cfg.RepoRoot) | ||
| gitpodService serverapi.APIInterface | ||
|
|
||
| notificationService = NewNotificationService() | ||
| ) | ||
|
|
||
| if !opts.RunGP { | ||
| gitpodService = serverapi.NewServerApiService(ctx, &serverapi.ServiceConfig{ | ||
| Host: host, | ||
|
|
@@ -818,13 +826,6 @@ func configureGit(cfg *Config) { | |
| settings = append(settings, []string{"user.email", cfg.GitEmail}) | ||
| } | ||
|
|
||
| if cfg.CommitAnnotationEnabled { | ||
| err := setupGitMessageHook(filepath.Join(cfg.RepoRoot, ".git", "hooks")) | ||
| if err != nil { | ||
| log.WithError(err).Error("cannot setup git message hook") | ||
| } | ||
| } | ||
|
|
||
| for _, s := range settings { | ||
| cmd := exec.Command("git", append([]string{"config", "--global"}, s...)...) | ||
| cmd = runAsGitpodUser(cmd) | ||
|
|
@@ -845,15 +846,21 @@ func setupGitMessageHook(path string) error { | |
| if err := os.MkdirAll(path, 0755); err != nil { | ||
| return err | ||
| } | ||
| if err := os.Chown(path, gitpodUID, gitpodGID); err != nil { | ||
|
||
| return err | ||
| } | ||
|
|
||
| fn := filepath.Join(path, "prepare-commit-msg") | ||
| // do not override existing hooks. Relevant for workspaces based off of prebuilds, which might already have a hook. | ||
| // do not override existing hooks | ||
| if _, err := os.Stat(fn); err == nil { | ||
| return nil | ||
| } | ||
| if err := os.WriteFile(fn, []byte(hookContent), 0755); err != nil { | ||
| return err | ||
| } | ||
| if err := os.Chown(fn, gitpodUID, gitpodGID); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filiptronicek What about moving the
go fun()...into `configureGit()´? Feels that would match the pattern we have going here, and reduces the noise on the outside. 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, will move it to reduce the LOC we have in the main supervisor func. The reason I put it here at first is to not have to pass the cstate around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
0712aea(#20548)