git-nearest 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: git-nearest
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Find the remote branches closest to your current branch, with ahead/behind counts and a compact jj-style graph.
5
5
  Project-URL: Homepage, https://github.com/hwei/git-nearest
6
6
  Project-URL: Issues, https://github.com/hwei/git-nearest/issues
@@ -20,6 +20,10 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  Which remote branch is my current branch closest to?
22
22
 
23
+ <img src="https://raw.githubusercontent.com/hwei/git-nearest/main/docs/img/table.svg" alt="git nearest output: a table of remote branches">
24
+
25
+ <details><summary>as text</summary>
26
+
23
27
  ```console
24
28
  $ git nearest
25
29
  @ HEAD -> fix-typo [1 staged, 1 untracked]
@@ -27,6 +31,7 @@ $ git nearest
27
31
  ↑8 ↓0 origin/feature/login 51eef8f5
28
32
  ↑9 ↓1 origin/release/1.2 fc1afa3b
29
33
  ```
34
+ </details>
30
35
 
31
36
  The first line shows where HEAD is and the state of the working tree: `[clean]`, or counts such as
32
37
  `[2 staged, 3 modified, 1 untracked]` (conflicted files turn it red). That is the thing to check
@@ -43,6 +48,10 @@ instead of having one picked for you.
43
48
  [`jj log`](https://docs.jj-vcs.dev/): newest on top (by commit date, parents never above their children), and runs of ordinary commits folded into a
44
49
  `~ (n)` row on the vertical line.
45
50
 
51
+ <img src="https://raw.githubusercontent.com/hwei/git-nearest/main/docs/img/graph.svg" alt="git nearest -g output: a graph of HEAD and remote branches">
52
+
53
+ <details><summary>as text</summary>
54
+
46
55
  ```console
47
56
  $ git nearest -g
48
57
  @ ae22273d HEAD -> fix-typo [1 staged, 1 untracked]
@@ -60,11 +69,12 @@ $ git nearest -g
60
69
  ○ 5a42fea0 merge-base
61
70
  ~ (n) = n commits folded between
62
71
  ```
72
+ </details>
63
73
 
64
74
  Only HEAD, the branch tips and the merge-bases between them are drawn. `(3)` means three commits sit
65
75
  between the nodes above and below it.
66
76
 
67
- Both examples are real output from a synthetic repository built by
77
+ Both examples (images and text) are real output from a synthetic repository built by
68
78
  [`scripts/demo.py`](https://github.com/hwei/git-nearest/blob/main/scripts/demo.py).
69
79
 
70
80
  ## Install
@@ -2,6 +2,10 @@
2
2
 
3
3
  Which remote branch is my current branch closest to?
4
4
 
5
+ <img src="https://raw.githubusercontent.com/hwei/git-nearest/main/docs/img/table.svg" alt="git nearest output: a table of remote branches">
6
+
7
+ <details><summary>as text</summary>
8
+
5
9
  ```console
6
10
  $ git nearest
7
11
  @ HEAD -> fix-typo [1 staged, 1 untracked]
@@ -9,6 +13,7 @@ $ git nearest
9
13
  ↑8 ↓0 origin/feature/login 51eef8f5
10
14
  ↑9 ↓1 origin/release/1.2 fc1afa3b
11
15
  ```
16
+ </details>
12
17
 
13
18
  The first line shows where HEAD is and the state of the working tree: `[clean]`, or counts such as
14
19
  `[2 staged, 3 modified, 1 untracked]` (conflicted files turn it red). That is the thing to check
@@ -25,6 +30,10 @@ instead of having one picked for you.
25
30
  [`jj log`](https://docs.jj-vcs.dev/): newest on top (by commit date, parents never above their children), and runs of ordinary commits folded into a
26
31
  `~ (n)` row on the vertical line.
27
32
 
33
+ <img src="https://raw.githubusercontent.com/hwei/git-nearest/main/docs/img/graph.svg" alt="git nearest -g output: a graph of HEAD and remote branches">
34
+
35
+ <details><summary>as text</summary>
36
+
28
37
  ```console
29
38
  $ git nearest -g
30
39
  @ ae22273d HEAD -> fix-typo [1 staged, 1 untracked]
@@ -42,11 +51,12 @@ $ git nearest -g
42
51
  ○ 5a42fea0 merge-base
43
52
  ~ (n) = n commits folded between
44
53
  ```
54
+ </details>
45
55
 
46
56
  Only HEAD, the branch tips and the merge-bases between them are drawn. `(3)` means three commits sit
47
57
  between the nodes above and below it.
48
58
 
49
- Both examples are real output from a synthetic repository built by
59
+ Both examples (images and text) are real output from a synthetic repository built by
50
60
  [`scripts/demo.py`](https://github.com/hwei/git-nearest/blob/main/scripts/demo.py).
51
61
 
52
62
  ## Install
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "git-nearest"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Find the remote branches closest to your current branch, with ahead/behind counts and a compact jj-style graph."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -1,3 +1,3 @@
1
1
  """Find the remote branches closest to HEAD."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
@@ -9,11 +9,11 @@ def render(rows, paint, base, head_line=None):
9
9
  wa, wb, wn = max(map(len, ups)), max(map(len, downs)), max(len(r.ref) for r in rows)
10
10
  lines = [head_line] if head_line else []
11
11
  for r, up, down in zip(rows, ups, downs):
12
- base = git("merge-base", "refs/remotes/" + r.ref, base, check=False)[:8]
12
+ mb = git("merge-base", "refs/remotes/" + r.ref, base, check=False)[:8]
13
13
  lines.append("%s %s %s %s" % (
14
14
  paint(color.GREEN, up.ljust(wa)),
15
15
  paint(color.RED, down.ljust(wb)),
16
16
  r.ref.ljust(wn),
17
- paint(color.DIM, base),
17
+ paint(color.DIM, mb),
18
18
  ))
19
19
  return lines
@@ -38,6 +38,9 @@ def repo(tmp_path, monkeypatch):
38
38
  monkeypatch.chdir(tmp_path)
39
39
  for k, v in ENV.items():
40
40
  monkeypatch.setenv(k, v)
41
+ # one fixed second: the graph orders by date, so commits straddling a second would change the layout
42
+ monkeypatch.setenv("GIT_COMMITTER_DATE", "1000000000 +0000")
43
+ monkeypatch.setenv("GIT_AUTHOR_DATE", "1000000000 +0000")
41
44
  return r
42
45
 
43
46
 
@@ -23,6 +23,13 @@ def test_table_orders_by_ahead_then_behind(forked, capsys):
23
23
  ]
24
24
 
25
25
 
26
+ def test_each_row_has_its_own_merge_base(forked, capsys):
27
+ main(["--color", "never"])
28
+ for line in capsys.readouterr().out.splitlines()[1:]:
29
+ _, _, ref, mb = line.split()
30
+ assert mb == forked.git("merge-base", "HEAD", "refs/remotes/" + ref)[:8]
31
+
32
+
26
33
  def test_limit(forked, capsys):
27
34
  _, out, _ = run(capsys, "1")
28
35
  assert out.splitlines() == ["@ HEAD -> work [clean]", "↑3 ↓0 origin/other H"]
File without changes
File without changes