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

Allow ocaml/opam-repository to be added to a opam-repositories without hash errors #647

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to

- Don't install Cygwin's git or mercurial packages (reduces cache by ~90MB)

### Fixed

- Ensure ocaml/opam-repository can be added without getting hash errors.

## [2.0.10]

### Fixed
Expand Down
28 changes: 28 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 31 additions & 1 deletion src/setup-ocaml/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from "node:path";
import * as process from "node:process";

import * as core from "@actions/core";
import { exec } from "@actions/exec";
import { exec, getExecOutput } from "@actions/exec";
import * as github from "@actions/github";
import * as io from "@actions/io";
import * as tc from "@actions/tool-cache";
Expand Down Expand Up @@ -334,10 +334,40 @@ async function repositoryAdd(name: string, address: string) {
export async function repositoryAddAll(
repositories: [string, string][]
): Promise<void> {
const platform = getPlatform();
let restore_autocrlf;
core.startGroup("Initialise the opam repositories");
// Works around the lack of https://github.com/ocaml/opam/pull/3882 when
// adding ocaml/opam-repository on Windows. Can be removed when the action
// switches to opam 2.2
if (platform === Platform.Win32) {
const autocrlf = await getExecOutput(
"git",
["config", "--global", "core.autocrlf"],
{ ignoreReturnCode: true }
);
if (autocrlf.stdout !== "input") {
if (autocrlf.exitCode !== 0) {
restore_autocrlf = null; // Unset the value at the end
} else {
restore_autocrlf = autocrlf.stdout;
}
}
await exec("git", ["config", "--global", "core.autocrlf", "input"]);
}
for (const [name, address] of repositories) {
await repositoryAdd(name, address);
}
if (restore_autocrlf === null) {
await exec("git", ["config", "--global", "--unset", "core.autocrlf"]);
} else if (restore_autocrlf !== undefined) {
await exec("git", [
"config",
"--global",
"core.autocrlf",
restore_autocrlf,
]);
}
core.endGroup();
}

Expand Down