summaryrefslogtreecommitdiff
path: root/source/comp/git.d
blob: 4f68e9504b2b0f9aff0a36c189e19390998859a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module comp.git;

import std.stdio;
import std.file : dirEntries, SpanMode;
import std.process;
import std.string : strip;

string gitBranch() {
  auto result = execute(["git", "rev-parse", "--abbrev-ref", "HEAD"]);

  if (result.status != 0)
    return null;

  return result.output.strip();
}

string gitStatus() {
  auto result = execute(["git", "status", "--porcelain"]);

  if (result.status != 0)
    return null;

  if (result.output.length >= 1) {
    return "*";
  }

  return "";
}