Skip to content

Commit

Permalink
fix: strip "v" from version during local development
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Jan 16, 2024
1 parent 614144d commit e47581a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Bitfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = %(git describe --tags --always --dirty)%
VERSION = %(git describe --tags --always --dirty | sed -e 's/^v//')%
DEST = build
RELEASE = %{DEST}/release

Expand Down
6 changes: 6 additions & 0 deletions cmd/ftl/cmd_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (d *devCmd) updateFileInfo(ctx context.Context, dir string) error {
ignores := initGitIgnore(ctx, dir)
d.modules[dir] = moduleFolderInfo{}

var changed string
err = walkDir(dir, ignores, func(srcPath string, entry fs.DirEntry) error {
for _, pattern := range config.Watch {
relativePath, err := filepath.Rel(dir, srcPath)
Expand All @@ -154,6 +155,7 @@ func (d *devCmd) updateFileInfo(ctx context.Context, dir string) error {
module := d.modules[dir]
module.NumFiles++
if fileInfo.ModTime().After(module.LastModTime) {
changed = srcPath
module.LastModTime = fileInfo.ModTime()
}
d.modules[dir] = module
Expand All @@ -163,6 +165,10 @@ func (d *devCmd) updateFileInfo(ctx context.Context, dir string) error {
return nil
})

if changed != "" {
log.FromContext(ctx).Tracef("Detected change in %s", changed)
}

return err
}

Expand Down
8 changes: 2 additions & 6 deletions go-runtime/compile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func genType(module *schema.Module, t schema.Type) string {
}

// Update go.mod file to include the FTL version.
func updateGoModule(goModPath string) (version string, err error) {
func updateGoModule(goModPath string) (string, error) {
goModBytes, err := os.ReadFile(goModPath)
if err != nil {
return "", fmt.Errorf("failed to read %s: %w", goModPath, err)
Expand All @@ -214,11 +214,7 @@ func updateGoModule(goModPath string) (version string, err error) {
return "", fmt.Errorf("failed to parse %s: %w", goModPath, err)
}
if ftl.IsRelease(ftl.Version) {
version := ftl.Version
if !strings.HasPrefix(version, "v") {
version = "v" + version
}
if err := goModfile.AddRequire("github.com/TBD54566975/ftl", version); err != nil {
if err := goModfile.AddRequire("github.com/TBD54566975/ftl", ftl.Version); err != nil {
return "", fmt.Errorf("failed to add github.com/TBD54566975/ftl to %s: %w", goModPath, err)
}
goModBytes = modfile.Format(goModfile.Syntax)
Expand Down

0 comments on commit e47581a

Please sign in to comment.