Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jul 30, 2024
1 parent f31a127 commit 880f729
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 33 deletions.
28 changes: 14 additions & 14 deletions admin/server/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
"github.com/google/go-github/v50/github"
"github.com/rilldata/rill/admin"
"github.com/rilldata/rill/admin/database"
"github.com/rilldata/rill/admin/pkg/archive"
"github.com/rilldata/rill/admin/pkg/gitutil"
"github.com/rilldata/rill/admin/pkg/urlutil"
"github.com/rilldata/rill/admin/server/auth"
adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1"
"github.com/rilldata/rill/runtime/pkg/archive"
"github.com/rilldata/rill/runtime/pkg/httputil"
"github.com/rilldata/rill/runtime/pkg/middleware"
"github.com/rilldata/rill/runtime/pkg/observability"
Expand Down Expand Up @@ -323,7 +323,7 @@ func (s *Server) ConnectProjectToGithub(ctx context.Context, req *adminv1.Connec

claims := auth.GetClaims(ctx)
if !claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID).ManageProject {
return nil, status.Error(codes.PermissionDenied, "does not have permission to delete project")
return nil, status.Error(codes.PermissionDenied, "does not have permission to update project's github connection")
}

user, err := s.admin.DB.FindUser(ctx, claims.OwnerID())
Expand Down Expand Up @@ -1006,18 +1006,18 @@ func (s *Server) pushToGit(ctx context.Context, copyData func(dir, projPath stri
SingleBranch: true,
})
if err != nil {
if errors.Is(err, transport.ErrEmptyRemoteRepository) {
empty = true
ghRepo, err = git.PlainInitWithOptions(gitPath, &git.PlainInitOptions{
InitOptions: git.InitOptions{
DefaultBranch: plumbing.NewBranchReferenceName(branch),
},
Bare: false,
})
if err != nil {
return fmt.Errorf("failed to init git repo: %w", err)
}
} else {
if !errors.Is(err, transport.ErrEmptyRemoteRepository) {
return fmt.Errorf("failed to init git repo: %w", err)
}

empty = true
ghRepo, err = git.PlainInitWithOptions(gitPath, &git.PlainInitOptions{
InitOptions: git.InitOptions{
DefaultBranch: plumbing.NewBranchReferenceName(branch),
},
Bare: false,
})
if err != nil {
return fmt.Errorf("failed to init git repo: %w", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/drivers/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/mitchellh/mapstructure"
"github.com/rilldata/rill/admin/client"
"github.com/rilldata/rill/admin/pkg/archive"
adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1"
"github.com/rilldata/rill/runtime/drivers"
"github.com/rilldata/rill/runtime/pkg/activity"
"github.com/rilldata/rill/runtime/pkg/archive"
"github.com/rilldata/rill/runtime/pkg/ctxsync"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
Expand Down
File renamed without changes.
18 changes: 7 additions & 11 deletions web-admin/src/features/projects/github/GithubConnectionUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,17 @@ export class GithubConnectionUpdater {
private readonly project: string,
) {}

public updateCurrentFields(
currentUrl: string,
currentSubpath: string,
currentBranch: string,
) {
this.githubUrl.set(currentUrl);
this.subpath.set(currentSubpath);
this.branch.set(currentBranch);
this.isConnected = !!currentUrl;
public init(githubUrl: string, subpath: string, branch: string) {
this.githubUrl.set(githubUrl);
this.subpath.set(subpath);
this.branch.set(branch);
this.isConnected = !!githubUrl;
}

public onRepoChange(repo: ListGithubUserReposResponseRepo) {
this.subpath.set("");
this.branch.set(repo.defaultBranch);
this.defaultBranch = repo.defaultBranch;
this.branch.set(repo.defaultBranch ?? "");
this.defaultBranch = repo.defaultBranch ?? "";
}

public async update({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
organization,
project,
);
$: githubConnectionUpdater.updateCurrentFields(
currentUrl,
currentSubpath,
currentBranch,
);
$: githubConnectionUpdater.init(currentUrl, currentSubpath, currentBranch);
const connectToGithubMutation =
githubConnectionUpdater.connectToGithubMutation;
Expand Down
2 changes: 0 additions & 2 deletions web-common/src/metrics/service/BehaviourEventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export enum BehaviourEventAction {
DeploySuccess = "deploy-success",
LoginStart = "login-start",
LoginSuccess = "login-success",
GithubConnectStart = "ghconnected-start",
GithubConnectSuccess = "ghconnected-success",

UserInvite = "user-invite",
UserDomainWhitelist = "user-domain-whitelist",
Expand Down

0 comments on commit 880f729

Please sign in to comment.