Skip to content

Commit d14a4bf

Browse files
committed
*: add a new flag --old-uast-serialization to serialize UASTs in the old way
Signed-off-by: Manuel Carmona <[email protected]>
1 parent d24b2cf commit d14a4bf

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cmd/gitbase/command/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type Server struct {
5656
DisableGit bool `long:"no-git" description:"disable the load of git standard repositories."`
5757
DisableSiva bool `long:"no-siva" description:"disable the load of siva files."`
5858
Verbose bool `short:"v" description:"Activates the verbose mode"`
59+
OldUast bool `long:"old-uast-serialization" description:"serialize uast in the old format" env:"GITBASE_UAST_SERIALIZATION"`
5960
}
6061

6162
type jaegerLogrus struct {
@@ -138,12 +139,17 @@ func (c *Server) Execute(args []string) error {
138139
c.engine,
139140
gitbase.NewSessionBuilder(c.pool,
140141
gitbase.WithSkipGitErrors(c.SkipGitErrors),
142+
gitbase.WithOldUASTSerialization(c.OldUast),
141143
),
142144
)
143145
if err != nil {
144146
return err
145147
}
146148

149+
if c.OldUast {
150+
function.UASTExpressionType = sql.Array(sql.Blob)
151+
}
152+
147153
logrus.Infof("server started and listening on %s:%d", c.Host, c.Port)
148154
return s.Start()
149155
}

session.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ type Session struct {
2525
bblfshEndpoint string
2626
bblfshClient *BblfshClient
2727

28-
SkipGitErrors bool
28+
SkipGitErrors bool
29+
OldUASTSerialization bool
2930
}
3031

3132
// getSession returns the gitbase session from a context or an error if there
@@ -65,6 +66,13 @@ func WithSkipGitErrors(enabled bool) SessionOption {
6566
}
6667
}
6768

69+
// WithOldUASTSerialization set the way UASTs must be serialized.
70+
func WithOldUASTSerialization(enabled bool) SessionOption {
71+
return func(s *Session) {
72+
s.OldUASTSerialization = enabled
73+
}
74+
}
75+
6876
// NewSession creates a new Session. It requires a repository pool and any
6977
// number of session options can be passed to configure the session.
7078
func NewSession(pool *RepositoryPool, opts ...SessionOption) *Session {

0 commit comments

Comments
 (0)