<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>build_tools/git_version_gen.sh - fork/fish-shell @ master</title>
<meta name="description" content="build_tools/git_version_gen.sh in fork/fish-shell at master.">
<meta property="og:title" content="build_tools/git_version_gen.sh - fork/fish-shell @ master">
<meta property="og:description" content="build_tools/git_version_gen.sh in fork/fish-shell at master.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="master" data-tip="605c466379a074cf1b5cdb2b62bc8071aab8b47b">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/fish-shell</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/fish-shell</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Johannes Altmanninger</span><span class="commit-message" data-commit="b60582ff758c3496f7f081b3885bf7093494fd4b">build.rs: remove code duplication in version computation</span><span class="snapshot-sha sha" data-commit="b60582ff758c3496f7f081b3885bf7093494fd4b">b60582ff7</span><time datetime="2026-01-12T10:59:12+01:00" title="2026-01-12 10:59:12 +0100">2026-01-12</time></p>
<header class="topbar"><details class="switcher"><summary>master</summary><div class="menu"><strong>branches</strong><a class="current" href="/fork/fish-shell/ref/master/">master</a><a class="all" href="/fork/fish-shell/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/fish-shell/">fish-shell</a> / <a href="/fork/fish-shell/ref/master/tree/build_tools/">build_tools</a> / <span class="cur">git_version_gen.sh</span></nav>
<span class="view-stats"><span>603 B</span><span>22 lines</span></span><span class="actions"><a class="raw" href="/fork/fish-shell/raw/2febce0f354f086bd9d8cbaaf837d2c771a86d62/build_tools/git_version_gen.sh">raw</a></span></header>
<pre class="code src language-bash"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-c>#!/bin/sh</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"><a-c># Originally from the git sources (GIT-VERSION-GEN)</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"><a-f>set</a-f> <a-co>-e</a-co></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"><a-c># Find the fish directory as two levels up from script directory.</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"><a-pr>FISH_BASE_DIR</a-pr>=<a-s>&quot;</a-s><a-eb>$( </a-eb><a-f>cd</a-f><a-eb> </a-eb><a-s>&quot;</a-s><a-eb>$( </a-eb><a-f>dirname</a-f><a-eb> </a-eb><a-s>&quot;</a-s><a-eb>$( </a-eb><a-f>dirname</a-f><a-eb> </a-eb><a-s>&quot;</a-s><a-o>$</a-o><a-s>0&quot;</a-s><a-eb> )</a-eb><a-s>&quot;</a-s><a-eb> )</a-eb><a-s>&quot;</a-s><a-eb> </a-eb><a-o>&amp;&amp;</a-o><a-eb> </a-eb><a-f>pwd</a-f><a-eb> )</a-eb><a-s>&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"><a-pr>version</a-pr>=<a-eb>$(</a-eb></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-eb>    </a-eb><a-f>awk</a-f><a-eb> </a-eb><a-o>&lt;</a-o><a-s>&quot;</a-s><a-o>$</a-o><a-pr>FISH_BASE_DIR</a-pr><a-s>/Cargo.toml&quot;</a-s><a-eb> -F</a-eb><a-s>&#39;&quot;&#39;</a-s><a-eb> </a-eb><a-s>&#39;$1 == &quot;version = &quot; { print $2 }&#39;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-eb>)</a-eb></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-k>if</a-k> <a-pr>git_version</a-pr>=<a-eb>$(</a-eb></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-eb>    </a-eb><a-pr>GIT_CEILING_DIRECTORIES</a-pr><a-eb>=</a-eb><a-o>$</a-o><a-pr>FISH_BASE_DIR</a-pr><a-eb>/.. \</a-eb></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-eb>        </a-eb><a-f>git</a-f><a-eb> </a-eb><a-co>-C</a-co><a-eb> </a-eb><a-s>&quot;</a-s><a-o>$</a-o><a-pr>FISH_BASE_DIR</a-pr><a-s>&quot;</a-s><a-eb> describe </a-eb><a-co>--always</a-co><a-eb> </a-eb><a-co>--dirty</a-co><a-eb> </a-eb><a-n>2</a-n><a-o>&gt;</a-o><a-eb>/dev/null)</a-eb>; <a-k>then</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text">    <a-k>if</a-k> [ <a-s>&quot;</a-s><a-o>$</a-o><a-pr>git_version</a-pr><a-s>&quot;</a-s> = <a-s>&quot;</a-s><a-eb>${</a-eb><a-pr>git_version</a-pr><a-eb>#</a-eb><a-s>&quot;</a-s><a-o>$</a-o><a-pr>version</a-pr><a-s>&quot;</a-s><a-eb>}</a-eb><a-s>&quot;</a-s> ]; <a-k>then</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text">        <a-pr>version</a-pr>=<a-o>$</a-o><a-pr>version</a-pr>-g<a-o>$</a-o><a-pr>git_version</a-pr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text">    <a-k>else</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text">        <a-pr>version</a-pr>=<a-o>$</a-o><a-pr>git_version</a-pr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text">    <a-k>fi</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-k>fi</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-f>echo</a-f> <a-s>&quot;</a-s><a-o>$</a-o><a-pr>version</a-pr><a-s>&quot;</a-s></span></span></pre>
</main>
</body>
</html>
