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: allow specifying external commit from submodule #1026

Merged
merged 2 commits into from
May 9, 2024

Conversation

mistydemeo
Copy link
Contributor

This is the companion to github-releases-repo; when targeting creating a commit in an external repo, where that repo is also checked out as a submodule of the repository in which the release is being run, this lets you consult the latest commit of that submodule and use that commit as the tag instead of whatever happens to be the latest commit in that repository.

@mistydemeo mistydemeo requested a review from Gankra May 8, 2024 23:59
@mistydemeo mistydemeo force-pushed the github-releases-repo-submodule branch 3 times, most recently from 374d178 to c8f9863 Compare May 9, 2024 00:21
Copy link
Member

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

impl seems basically solid, some fixes needed

@@ -577,6 +577,7 @@ jobs:
owner: {{{ github_releases_repo.owner }}}
repo: {{{ github_releases_repo.repo }}}
token: ${{ secrets.GH_RELEASES_TOKEN }}
commit: ${{ fromJson(needs.host.outputs.val).ci.github.external_repo_commit }}
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be wrapped in some kind of if, since it should only be done if the submodule config is set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe if it's passed as null, it's functionally the same as if it weren't passed at all - that's why I didn't do any kind of "if" here. https://github.com/ncipollo/release-action/blob/1cbdc80532ba923d3d81ebd1cece305c437b8d66/src/Inputs.ts#L110-L116

Copy link
Member

Choose a reason for hiding this comment

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

Will that still work right if we make external_repo_commit skip_serializing_if?

Copy link
Member

Choose a reason for hiding this comment

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

(probably?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I guess I'm passing it as an empty string if not set - should fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After we did a little looking, we've settled on that this should work as-is.

cargo-dist-schema/src/lib.rs Show resolved Hide resolved
// history that aren't reflected by the submodule commit history,
// won't be reflected here.
fn submodule_head(submodule_path: &Utf8PathBuf) -> DistResult<String> {
let output = Cmd::new("git", "fetch expected latest commit for a submodule")
Copy link
Member

Choose a reason for hiding this comment

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

This isn't the format of the error string, it's an explanation of what we were trying to do (gets prefixed with "failed to"). So it should be like "get submodule commit".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, sorry, "expected" wasn't meant as an error message - it was because this fetches the cached/configured (eg "expected") commit of the submodule rather than what's currently there on disk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to the technical git term, "cached".

.arg(submodule_path)
.output()
.map_err(|_| DistError::GitSubmoduleCommitError {
path: submodule_path.to_string(),
Copy link
Member

Choose a reason for hiding this comment

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

Should this wrap the axoprocess error? Oh I see, the other path doesn't have that.


let line = String::from_utf8_lossy(&output.stdout);
// Format: one status character, commit, a space, repo name
let line = line.trim_start_matches([' ', '-', '+']);
Copy link
Member

Choose a reason for hiding this comment

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

neat!

@mistydemeo mistydemeo force-pushed the github-releases-repo-submodule branch 2 times, most recently from b607671 to ed4330b Compare May 9, 2024 17:23
This is used with `github_releases_repo` to specify that the commit
to tag is the commit that's the current HEAD of submodule within this
repo.
@mistydemeo mistydemeo force-pushed the github-releases-repo-submodule branch from ed4330b to 4323899 Compare May 9, 2024 17:47
@mistydemeo mistydemeo merged commit e64776d into main May 9, 2024
16 checks passed
@mistydemeo mistydemeo deleted the github-releases-repo-submodule branch May 9, 2024 18:03
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.

None yet

2 participants