Replies: 3 comments
-
Ah yeah this looks like a bug and the rewritten code is much better, but still needs to be fixed. I think the logic is correct if If auto_version isn't set, def determine_workflow_update(auto_version, workflow, existing_workflow):
if not auto_version and existing_workflow and existing_workflow.versions:
return workflow.version != existing_workflow.versions[0].version, workflow.version
if workflow.version == "":
return True, "v0.1.0"
if existing_workflow and existing_workflow.versions:
new_version = bump_minor_version(
existing_workflow.versions[0].version)
should_put = new_version != workflow.version
return [should_put, new_version]
return [True, workflow.version] This seems to match up much better with the Go SDK: shouldPut := opts.autoVersion
if err != nil {
// if not found, create
if statusErr, ok := status.FromError(err); ok && statusErr.Code() == codes.NotFound {
shouldPut = true
} else {
return fmt.Errorf("could not get workflow: %w", err)
}
if workflow.Version == "" && opts.autoVersion {
req.Opts.Version = "0.1.0"
}
} else {
// if there are no versions, exit
if len(apiWorkflow.Versions) == 0 {
return fmt.Errorf("found workflow, but it has no versions")
}
// get the workflow version to determine whether to update
if apiWorkflow.Versions[0].Version != workflow.Version {
shouldPut = true
}
if workflow.Version == "" && opts.autoVersion {
req.Opts.Version, err = bumpMinorVersion(apiWorkflow.Versions[0].Version)
if err != nil {
return fmt.Errorf("could not bump version: %w", err)
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok, I opened issue #123 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@abelanger5 I'm trying to wrap my head around this code as I port to TS.
It looks like there are a few unreachable branches since we're checking auto_version at the beginning.
Thoughts on rewriting this using a guard pattern for legibility? I believe this is written with the same functionality as the original code:
Also, we're setting
should_put
on line 43 but implicitly setting it to False at the start of this block. Was that intentional?Beta Was this translation helpful? Give feedback.
All reactions