Skip to content
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

feat: Include updated images in commit message #49

Merged
merged 9 commits into from
Apr 22, 2024

Conversation

tsmalls93
Copy link
Contributor

@tsmalls93 tsmalls93 commented Apr 16, 2024

Fixes #48

@tsmalls93 tsmalls93 marked this pull request as draft April 16, 2024 13:45
@tsmalls93 tsmalls93 marked this pull request as ready for review April 16, 2024 16:34
@bluebrown
Copy link
Owner

Hi, thank you for the effort! I am a little bit confused about this design. Like moving it into the decoder.

What is the benefit of this vs ranging over the actual changes reported by the krm filter?

@bluebrown
Copy link
Owner

Dont worry about the ci failure. I put a failing test in main, on purpose. I will fix that one now, then you could rebase main to get this CI green.

@bluebrown
Copy link
Owner

I have fixed the test a92a2d2

@tsmalls93
Copy link
Contributor Author

Hi, thank you for the effort! I am a little bit confused about this design. Like moving it into the decoder.

What is the benefit of this vs ranging over the actual changes reported by the krm filter?

So, the solution you had in mind was to construct the commit message from the changes array that is returned from the Pipeline function? That probably would have been easier if I had thought of that. I suppose the only benefit to my solution is it gives more control to the user, but either solution would work for my use case.

@tsmalls93
Copy link
Contributor Author

Oh, I see. The image(s) being sent to the decoder won't necessarily result in a change.

@tsmalls93 tsmalls93 changed the title feat: Allow scriptable commit messages feat: Include updated images in commit message Apr 16, 2024
@bluebrown
Copy link
Owner

bluebrown commented Apr 17, 2024

Oh, I see. The image(s) being sent to the decoder won't necessarily result in a change.

Yes, that is one thing. And another thing is that multiple events can could run as batch. So it may change serveral image refs, in your repo, at once. Depending on the debounce timer and so on.

I did experiment with tracking changes in the past, doing file diffs and so on. But at the end a semantic diff is probably the best, in order to avoid false positives due to things like white space and indentation changes.

So I found it most solid to have the filter track and report the changes it makes.

@@ -43,8 +43,10 @@ func KoboldHandler(ctx context.Context, cache string, g model.TaskGroup, runner
g.DestBranch.String = g.RepoUri.Ref
g.DestBranch.Valid = true
}

msg = "chore(kobold): update image refs"
msg, err = GetCommitMessage(changes)
Copy link
Owner

@bluebrown bluebrown Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could make changes a slice of structs with structured data so we don't have to use regex.

Copy link
Owner

@bluebrown bluebrown Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess here the type needs to be changed to some struct type:

Changes []string

@bluebrown
Copy link
Owner

you can run the checks locally

###@ Checks
. golangci has also something like a --fix flag, Iu think.

@tsmalls93
Copy link
Contributor Author

you can run the checks locally

###@ Checks

. golangci has also something like a --fix flag, Iu think.

Yeah, I'm getting different errors and the linting seems to give up after them. It is not liking the copyDir file seemingly because I am on an arm64 Mac and not x86_64 Linux. I think I got the import issues fixed though.

@tsmalls93
Copy link
Contributor Author

Maybe I can make an Apple Silicon specific Makefile in a future PR.

@bluebrown
Copy link
Owner

bluebrown commented Apr 20, 2024

you can run the checks locally

###@ Checks

. golangci has also something like a --fix flag, Iu think.

Yeah, I'm getting different errors and the linting seems to give up after them. It is not liking the copyDir file seemingly because I am on an arm64 Mac and not x86_64 Linux. I think I got the import issues fixed though.

Go has build tags. Some of them are architecture specific. As a shortcut, if you suffix a file with an architecutre, it will be only build on that arch, like if you would have used a build tag.

You could create a file called copy_darwin.go and put some mac specific copy command there. The reason its guarded is because its using exec to run an external command.

Like this one, but for darwin: https://github.com/bluebrown/kobold/blob/main/git/copy_linux.go

@tsmalls93
Copy link
Contributor Author

Gotcha. I ended up renaming it to copy.go and adding //go:build linux || darwin to the top of the file, since it would be the same code. That made the error go away. I didn't commit it since my build issues are out of scope for this PR, but I'll do some work to get it to be compatible with arm64 Darwin.

@bluebrown
Copy link
Owner

Hi, thanks. Do you think its good now ? Should we maybe add a few tests?

@tsmalls93
Copy link
Contributor Author

Yeah, I think it is good now. I just added a couple tests.

@bluebrown bluebrown merged commit aab019c into bluebrown:main Apr 22, 2024
1 check passed
@bluebrown
Copy link
Owner

bluebrown commented Apr 22, 2024

hi @tsmalls93 , thanks. I build and pushed the latest main as image: docker.io/bluebrown/kobold:aab019c

Its not released yet but you can use that one already, if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to customize commit message
2 participants