From 6d9d4859cc3a2b0130f0bd07ccecba5371ae85c8 Mon Sep 17 00:00:00 2001 From: LeedsJohn <94880155+LeedsJohn@users.noreply.github.com> Date: Sat, 30 Dec 2023 09:22:18 -0600 Subject: [PATCH] [#10] Use pure function instead of calling 'basename' (#34) * Used Core.Filename.basename to find base name * Add to contributors --- CHANGELOG.md | 4 ++++ lib/git.ml | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1002af9..8cb19a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ available [on GitHub][2]. - [#31](https://github.com/chshersh/zbg/pull/31): Command `zbg push -f` now uses git's `--force-with-lease` because it's a safer default (by [@kephas]) +-[#10](https://github.com/chshersh/zbg/issues/10): + Changed `fetch_main_branch` to get the base name using `Core.Filename.basename` rather than reading the output of the `basename` command. + (by [@leedsjohn]) ## [0.2.0] — 2023-12-17 🎄 @@ -51,6 +54,7 @@ Initial release prepared by [@chshersh]. [@chshersh]: https://github.com/chshersh +[@leedsjohn]: https://github.com/leedsjohn [@paulpatault]: https://github.com/paulpatault [@sloboegen]: https://github.com/sloboegen [@tekknoid]: https://github.com/tekknoid diff --git a/lib/git.ml b/lib/git.ml index fbde53c..a0a3d73 100644 --- a/lib/git.ml +++ b/lib/git.ml @@ -9,8 +9,7 @@ let fetch_main_branch () : string = let remote_main_branch = Process.proc_stdout "git rev-parse --abbrev-ref origin/HEAD" in - Process.proc_stdout @@ Printf.sprintf "basename %s" remote_main_branch -(* TODO: use pure function *) + Core.Filename.basename remote_main_branch let branch_or_main (branch_opt : string option) : string = match branch_opt with