mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-12 15:22:55 +01:00
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { git } from "./client";
|
|
|
|
/**
|
|
* Update the ref to a new value.
|
|
*
|
|
* @param repositoryDir - The repository in which the ref exists.
|
|
* @param ref - The ref to update. Must be fully qualified
|
|
* (e.g., `refs/heads/NAME`).
|
|
* @param oldValue - The value we expect the ref to have currently. If it
|
|
* doesn't match, the update will be aborted.
|
|
* @param newValue - The new value for the ref.
|
|
* @param reason - The reflog entry.
|
|
*/
|
|
export async function updateRef(
|
|
repositoryDir: string,
|
|
ref: string,
|
|
oldValue: string,
|
|
newValue: string,
|
|
reason: string
|
|
): Promise<void> {
|
|
await git(
|
|
["update-ref", ref, newValue, oldValue, "-m", reason],
|
|
repositoryDir,
|
|
"updateRef"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Remove a ref.
|
|
*
|
|
* @param repositoryDir - The repository in which the ref exists.
|
|
* @param ref - The ref to remove. Should be fully qualified, but may also be 'HEAD'.
|
|
* @param reason - The reflog entry (optional). Note that this is only useful when
|
|
* deleting the HEAD reference as deleting any other reference will
|
|
* implicitly delete the reflog file for that reference as well.
|
|
*/
|
|
export async function deleteRef(
|
|
repositoryDir: string,
|
|
ref: string,
|
|
reason?: string
|
|
) {
|
|
const args = ["update-ref", "-d", ref];
|
|
|
|
if (reason !== undefined) {
|
|
args.push("-m", reason);
|
|
}
|
|
|
|
return await git(args, repositoryDir, "deleteRef");
|
|
}
|