Skip to content

GitVersion 5.0.1 resolves wrong commit count after merge based on wrong VersionSourceSha #1830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlexEngblom opened this issue Sep 27, 2019 · 27 comments
Labels

Comments

@AlexEngblom
Copy link

After merging new release with related tag to master to development, GitVersion resolves way too big commit count. This issue seems to be that for some reason the previous release commit to master branch was used as VersionSource,

We noticed this because for whatever reasons, one of our build agents resolved the numbering properly (however the base version was resolved to merge tag commit instead of merge branch commit!), thus we ended up with mixed version incrementation.

Deleting the .git/gitversion-cache didn't help.
Downgrading to 4.0.0 fixed the issues.

GitVersion information:
5.0.1+Branch.master.Sha.c71b8fc9f6d7b6adffe82fef588e717beb864e91

GitVersion diag from 5.0.1:
INFO [09/27/19 8:50:21:67] Found multiple base versions which will produce the same SemVer (1.9.0), taking oldest source for commit counting (Merge message 'Merge branch 'release/1.8.0'')
INFO [09/27/19 8:50:21:68] Base version used: Merge message 'Merge branch 'release/1.8.0'': 1.8.0 with commit count source c81b4597a898cc49806f8e57d8e60df7bc1c82db (Incremented: 1.9.0)
INFO [09/27/19 8:50:21:69] End: Calculating base versions (Took: 2,404.09ms)
INFO [09/27/19 8:50:21:71] 64 commits found between c81b4597a898cc49806f8e57d8e60df7bc1c82db and 7c0742d94ec4c1da00d690ad0b93fadc43f14cdc

GitVersion diag from 4.0.0:
INFO [09/27/19 8:46:26:79] Found multiple base versions which will produce the same SemVer (1.9.0), taking oldest source for commit counting (Merge message 'Merge branch 'release/1.8.0'')
INFO [09/27/19 8:46:26:80] Base version used: Merge message 'Merge branch 'release/1.8.0'': 1.8.0 with commit count source f0351a3d24578e6bb42e0f0ad81bf259c25b07d4 (Incremented: 1.9.0)
INFO [09/27/19 8:46:26:80] End: Calculating base versions (Took: 3,701.51ms)
INFO [09/27/19 8:46:26:81] 11 commits found between f0351a3d24578e6bb42e0f0ad81bf259c25b07d4 and 7c0742d94ec4c1da00d690ad0b93fadc43f14cdc

Related merge commits:

commit d096c0432e7c54b67c8b06ac2b445acd004237e9
Merge: baff1bb f0351a3
Date: Tue Sep 24 10:13:21 2019 +0300
Merge tag '1.8.0' into development
1.8.0

commit f0351a3d24578e6bb42e0f0ad81bf259c25b07d4 (tag: 1.8.0)
Merge: c81b459 baff1bb
Date: Tue Sep 24 10:13:19 2019 +0300
Merge branch 'release/1.8.0'

@asbjornu
Copy link
Member

Are you able to express the problem you're seeing as a RepositoryFixture test in a pull request, or draw your commit log somehow so I can see where the commits c81b4597a898cc49806f8e57d8e60df7bc1c82db, f0351a3d24578e6bb42e0f0ad81bf259c25b07d4 and 7c0742d94ec4c1da00d690ad0b93fadc43f14cdc are in the graph, respectively?

@newegor
Copy link

newegor commented Nov 17, 2019

I think I have the same issue. gv -diag option output:

gv -diag

INFO [11/17/19 12:20:53:08] Dumping commit graph:
INFO [11/17/19 12:20:53:17] * 9ede6fa 22 hours ago (HEAD -> develop)
|
| * 651959a 22 hours ago (tag: v.12.0.0, master)
| |
| | * cea8803 22 hours ago
| |/
|/|

  • | b553830 22 hours ago
  • | 2dfcb69 22 hours ago
    |\
    | | * 1b7cf2a 22 hours ago (tag: v.11.0.0)
    | | |
    | | |/
    | |/|
    | * | c6ab3b4 22 hours ago
    |/ /
  • | cea20b0 23 hours ago
    |\
    | |/
    | * d8b9088 23 hours ago (tag: v.10.0.0)
    | |
    | | * 8bcd987 23 hours ago
    | |/
    |/|
  • | f4e4321 23 hours ago
  • | b4b7ddb 2 days ago
    |\
    | |/
    | * 9d36bad 2 days ago (tag: v.9.0.0)
    | |
    | | * 1065af5 2 days ago
  • | | 8c31274 2 days ago
    | |/
    |/|
  • | 0a9202e 2 days ago
  • | 8408814 2 days ago
  • | 0541866 2 days ago
    |\
    | |/
    | * d1d65fc 2 days ago (tag: v.8.0.0)
    | |
    | | * fbc83f5 2 days ago
    | |/
    |/|
  • | a12bf20 2 days ago
  • | 8b85226 2 days ago (origin/develop)
    |\
    | |/
    | * 11f4964 2 days ago (tag: v.7.0.0, origin/master)
    | |
    | | * e3fb368 2 days ago
    | |/
    |/|
  • | 4fb97b4 2 days ago
  • | a39253c 2 days ago
    |\
    | |/
    | * 649c542 2 days ago (tag: v.6.0.0)
    | |
    | | * 854f239 2 days ago
    | |/
    |/|
  • | f8d7eec 2 days ago
  • | 45dccbf 2 days ago
  • | 5051b3b 2 days ago
    |\
    | |/
    | * 0ba5fc7 2 days ago (tag: v.5.0.0)
    | |
    | |/
    |/|
  • | e837d58 2 days ago
  • | 2241574 2 days ago
    |\
    | |/
    | * fe9735e 2 days ago (tag: v.4.0.0)
    | |
    | | * 9060390 2 days ago
    | |/
    |/|
  • | 2a1a40d 2 days ago
  • | 30e6147 2 days ago
    |\
    | |/
    | * 48a5370 2 days ago (tag: v.3.0.0)
    | |
    | | * 2d9aada 2 days ago
    | |/
    |/|
  • | 01bf105 6 days ago
  • | 1588761 6 days ago
  • | 5786d41 6 days ago
  • | 4d348e3 6 days ago
  • | 40700f5 6 days ago
  • | 86a6a7f 6 days ago
  • | b3a4a3c 6 days ago
  • | b792555 6 days ago
  • | a40fb2a 6 days ago
  • | b131927 7 days ago
  • | 7801f29 7 days ago
  • | f3a936c 7 days ago
    |\
    | |/
    | * 1d75d96 7 days ago (tag: v.2.5.0)
    | |
    | | * c675421 7 days ago
    | |/
    |/|
  • | 95c8065 7 days ago
  • | 0b786e0 7 days ago
  • | 2a95db7 7 days ago
    |\
    | |/
    | * 7e81449 7 days ago (tag: v.2.0.0)
    | |
    | | * c3f4b3c 7 days ago
    | |/
    |/|
  • | c1080da 7 days ago
  • | 4e6f5a8 7 days ago
    |\
    | |/
    | * 7736de6 7 days ago
    | |
    | | * c8df292 7 days ago
    | | * 516fc53 7 days ago
    | | * aac0c86 7 days ago
    | |/
  • | 988ec97 7 days ago
  • | 2a40f4f 7 days ago
    |\
    | |/
    | * 3db34b6 7 days ago (tag: 1.3.0)
    | |
    | | * 8a58ead 7 days ago
    | |/
    |/|
  • | 760f76e 7 days ago
  • | 28736b1 7 days ago
  • | 2c7a8d2 7 days ago
    |\
    | |/
    | * c068bd3 7 days ago (tag: v.1.0.0)
    | |
    | |/
    |/|
  • | b94feed 7 days ago
  • | 520dbdb 7 days ago
    |/
  • 1d8d0f1 6 months ago
  • b590744 12 months ago
  • 78bc052 1 year, 1 month ago
  • 5625832 2 years, 5 months ago
  • 8112c93 2 years, 5 months ago
  • f4698af 2 years, 5 months ago
  • b22a27b 6 years ago
    |
    | * b3d4291 6 years ago
    | * 4803c64 6 years ago
  • | 1847cb7 6 years ago
    |\
    | |/
    |/|
    | * 1b78afd 6 years ago
    | |
    | * | e28dd60 6 years ago
    | * | bd19f6a 6 years ago
  • | | 41da761 6 years ago (tag: ver-1.0)
    | |/
    |/|
  • | bb90a49 6 years ago
    |/
  • 5a4efaf 7 years ago
  • a6a5ba3 7 years ago
  • 493fc79 7 years ago

INFO [11/17/19 12:20:53:17] Working directory: D:\work\repo\testrepo
INFO [11/17/19 12:20:53:17] IsDynamicGitRepository: False
INFO [11/17/19 12:20:53:19] Returning Project Root from DotGitDirectory: D:\work\repo\testrepo.git\ - D:\work\repo\testrepo
INFO [11/17/19 12:20:53:19] Running on Windows.
INFO [11/17/19 12:20:53:19] Project root is: D:\work\repo\testrepo
INFO [11/17/19 12:20:53:19] DotGit directory is: D:\work\repo\testrepo.git
INFO [11/17/19 12:20:53:36] Using latest commit on specified branch
INFO [11/17/19 12:20:53:39] Running against branch: develop (9ede6faa985e77381dce972ab31cad9eacdd4fcd)
INFO [11/17/19 12:20:53:39] Begin: Calculating base versions
INFO [11/17/19 12:20:53:41] Fallback base version: 0.1.0 with commit count source 493fc791283fca667b4fed427cfb7ff7906c606f (Incremented: None)
INFO [11/17/19 12:20:53:47] Git tag 'v.12.0.0': 12.0.0 with commit count source 651959ac5b7fafc9ee45faad3ea5db14135f5cb7 (Incremented: 12.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.11.0.0': 11.0.0 with commit count source 1b7cf2a2ff1a58049561bb8d953bbf2e2314b1d3 (Incremented: 11.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.10.0.0': 10.0.0 with commit count source d8b9088a2527b81c88cf60fbd9bdc575f868233e (Incremented: 10.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.9.0.0': 9.0.0 with commit count source 9d36bad049589f6d8d5d6b4aebf71023f645f88f (Incremented: 9.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.8.0.0': 8.0.0 with commit count source d1d65fc681544f04de5af09ec8905ce6e273d698 (Incremented: 8.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.7.0.0': 7.0.0 with commit count source 11f4964d4cea5c87aa31138fabf69d101bdbc276 (Incremented: 7.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.6.0.0': 6.0.0 with commit count source 649c54200eb592b4a984b68a578c3f9c729db5a4 (Incremented: 6.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.5.0.0': 5.0.0 with commit count source 0ba5fc7223705697ac90f677eb5596875db7eed0 (Incremented: 5.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.4.0.0': 4.0.0 with commit count source fe9735e825612684a01b2bbbb324a858b148c976 (Incremented: 4.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.3.0.0': 3.0.0 with commit count source 48a5370976af93c2bd5edebd60861fabfe5a4999 (Incremented: 3.1.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.2.5.0': 2.5.0 with commit count source 1d75d9644f95ec29d467f5b2cb1a83dd4497ff87 (Incremented: 2.6.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.2.0.0': 2.0.0 with commit count source 7e81449c8237d597113bea5c1cbe528c57356dae (Incremented: 2.1.0)
INFO [11/17/19 12:20:53:47] Git tag '1.3.0': 1.3.0 with commit count source 3db34b6cea1f1018cd5651a49f4047784dc6f2ec (Incremented: 1.4.0)
INFO [11/17/19 12:20:53:47] Git tag 'v.1.0.0': 1.0.0 with commit count source c068bd3f531fea5fe777ab77c8720ade208e9897 (Incremented: 1.1.0)
INFO [11/17/19 12:20:53:49] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:49] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:49] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:49] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:49] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:50] Found commit [9ede6faa985e77381dce972ab31cad9eacdd4fcd] matching merge message format: Default
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.12.0.0'': 12.0.0 with commit count source 651959ac5b7fafc9ee45faad3ea5db14135f5cb7 (Incremented: 12.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.11.0.0' into develop': 11.0.0 with commit count source 2dfcb691ab739187ade748f61ee0d5349e8fc3d9 (Incremented: 11.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.11.0.0'': 11.0.0 with commit count source 1b7cf2a2ff1a58049561bb8d953bbf2e2314b1d3 (Incremented: 11.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.10.0.0'': 10.0.0 with commit count source d8b9088a2527b81c88cf60fbd9bdc575f868233e (Incremented: 10.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.9.0.0'': 9.0.0 with commit count source 9d36bad049589f6d8d5d6b4aebf71023f645f88f (Incremented: 9.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.8.0.0'': 8.0.0 with commit count source d1d65fc681544f04de5af09ec8905ce6e273d698 (Incremented: 8.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.7.0.0'': 7.0.0 with commit count source 11f4964d4cea5c87aa31138fabf69d101bdbc276 (Incremented: 7.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.6.0.0'': 6.0.0 with commit count source 649c54200eb592b4a984b68a578c3f9c729db5a4 (Incremented: 6.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.5.0.0'': 5.0.0 with commit count source 0ba5fc7223705697ac90f677eb5596875db7eed0 (Incremented: 5.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.4.0.0'': 4.0.0 with commit count source fe9735e825612684a01b2bbbb324a858b148c976 (Incremented: 4.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.3.0.0'': 3.0.0 with commit count source 48a5370976af93c2bd5edebd60861fabfe5a4999 (Incremented: 3.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.2.5.0'': 2.5.0 with commit count source 1d75d9644f95ec29d467f5b2cb1a83dd4497ff87 (Incremented: 2.6.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.2.0.0'': 2.0.0 with commit count source 7e81449c8237d597113bea5c1cbe528c57356dae (Incremented: 2.1.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/1.3.0'': 1.3.0 with commit count source 3db34b6cea1f1018cd5651a49f4047784dc6f2ec (Incremented: 1.4.0)
INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.1.0.0'': 1.0.0 with commit count source c068bd3f531fea5fe777ab77c8720ade208e9897 (Incremented: 1.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.12.0.0': 12.0.0 with commit count source 651959ac5b7fafc9ee45faad3ea5db14135f5cb7 (Incremented: 12.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.11.0.0': 11.0.0 with commit count source 1b7cf2a2ff1a58049561bb8d953bbf2e2314b1d3 (Incremented: 11.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.10.0.0': 10.0.0 with commit count source d8b9088a2527b81c88cf60fbd9bdc575f868233e (Incremented: 10.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.9.0.0': 9.0.0 with commit count source 9d36bad049589f6d8d5d6b4aebf71023f645f88f (Incremented: 9.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.8.0.0': 8.0.0 with commit count source d1d65fc681544f04de5af09ec8905ce6e273d698 (Incremented: 8.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.7.0.0': 7.0.0 with commit count source 11f4964d4cea5c87aa31138fabf69d101bdbc276 (Incremented: 7.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.6.0.0': 6.0.0 with commit count source 649c54200eb592b4a984b68a578c3f9c729db5a4 (Incremented: 6.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.5.0.0': 5.0.0 with commit count source 0ba5fc7223705697ac90f677eb5596875db7eed0 (Incremented: 5.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.4.0.0': 4.0.0 with commit count source fe9735e825612684a01b2bbbb324a858b148c976 (Incremented: 4.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.3.0.0': 3.0.0 with commit count source 48a5370976af93c2bd5edebd60861fabfe5a4999 (Incremented: 3.1.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.2.5.0': 2.5.0 with commit count source 1d75d9644f95ec29d467f5b2cb1a83dd4497ff87 (Incremented: 2.6.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.2.0.0': 2.0.0 with commit count source 7e81449c8237d597113bea5c1cbe528c57356dae (Incremented: 2.1.0)
INFO [11/17/19 12:20:53:55] Git tag '1.3.0': 1.3.0 with commit count source 3db34b6cea1f1018cd5651a49f4047784dc6f2ec (Incremented: 1.4.0)
INFO [11/17/19 12:20:53:55] Git tag 'v.1.0.0': 1.0.0 with commit count source c068bd3f531fea5fe777ab77c8720ade208e9897 (Incremented: 1.1.0)
INFO [11/17/19 12:20:53:57] Found multiple base versions which will produce the same SemVer (12.1.0), taking oldest source for commit counting (Merge message 'Merge branch 'release/v.12.0.0'')
INFO [11/17/19 12:20:53:57] Base version used: Merge message 'Merge branch 'release/v.12.0.0'': 12.0.0 with commit count source c6ab3b4eee5136be4e196d2fc974ddf5268e3fb1 (Incremented: 12.1.0)
INFO [11/17/19 12:20:53:57] End: Calculating base versions (Took: 187.59ms)
INFO [11/17/19 12:20:53:58] 6 commits found between c6ab3b4eee5136be4e196d2fc974ddf5268e3fb1 and 9ede6faa985e77381dce972ab31cad9eacdd4fcd
INFO [11/17/19 12:20:53:58] Begin: Getting version tags from branch 'refs/heads/develop'.
INFO [11/17/19 12:20:53:60] End: Getting version tags from branch 'refs/heads/develop'. (Took: 17.66ms)

Take a look at the line INFO [11/17/19 12:20:53:57] Base version used: Merge message 'Merge branch 'release/v.12.0.0'': 12.0.0 with commit count source c6ab3b4eee5136be4e196d2fc974ddf5268e3fb1 (Incremented: 12.1.0)

But on one previous line INFO [11/17/19 12:20:53:52] Merge message 'Merge branch 'release/v.12.0.0'': 12.0.0 with commit count source 651959ac5b7fafc9ee45faad3ea5db14135f5cb7 (Incremented: 12.1.0)

I see different commit count source.

General observation: if I use git flow commands for release branch end I see wrong behaviour, if I follow git flow manually for the same release branch end I see correct commint count source.
Manual commands l use the following:
  git merge --no-ff release/1.2.0
  git tag -a 1.2.0
  git checkout develop
  git merge --no-ff release/1.2.0
  git branch -d release/1.2.0

History looks different it these two cases. You can see tag v.12.0.0 was created using git flow extension. Tag v.11.0.0 was created manually.

@asbjornu
Copy link
Member

Are you able to reproduce this problem in a RepositoryFixture as asked in #1830 (comment), @newegor?

@Partovic
Copy link

I'm having the same issues since I upgraded to the latest version. VersionSource doesn't seem to be set correctly. After merging a release, it should use this commit as the version source until another release will be made.
GITVERSION_1

GITVERSION_2

@asbjornu
Copy link
Member

Until someone are able to reproduce this in a RepositoryFixture or at least point to a public repository that demonstrates the problem, it's going to be very hard to fix it.

@stale
Copy link

stale bot commented Mar 15, 2020

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 15, 2020
@asbjornu
Copy link
Member

Is this still a problem in GitVersion 5.2.4?

@stale stale bot removed the stale label Mar 19, 2020
@newegor
Copy link

newegor commented Mar 23, 2020

Yes. I've just checked and the issue is still presented. I shared a repo to see this issue https://[email protected]/newegor/testrepo.git

@asbjornu
Copy link
Member

@newegor, When running GitVersion on that repository, I get the following:

{
  "Major":12,
  "Minor":0,
  "Patch":0,
  "PreReleaseTag":"",
  "PreReleaseTagWithDash":"",
  "PreReleaseLabel":"",
  "PreReleaseNumber":"",
  "WeightedPreReleaseNumber":"",
  "BuildMetaData":5,
  "BuildMetaDataPadded":"0005",
  "FullBuildMetaData":"5.Branch.master.Sha.651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "MajorMinorPatch":"12.0.0",
  "SemVer":"12.0.0",
  "LegacySemVer":"12.0.0",
  "LegacySemVerPadded":"12.0.0",
  "AssemblySemVer":"12.0.0.0",
  "AssemblySemFileVer":"12.0.0.0",
  "FullSemVer":"12.0.0+5",
  "InformationalVersion":"12.0.0+5.Branch.master.Sha.651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "BranchName":"master",
  "Sha":"651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "ShortSha":"651959a",
  "NuGetVersionV2":"12.0.0",
  "NuGetVersion":"12.0.0",
  "NuGetPreReleaseTagV2":"",
  "NuGetPreReleaseTag":"",
  "VersionSourceSha":"c6ab3b4eee5136be4e196d2fc974ddf5268e3fb1",
  "CommitsSinceVersionSource":5,
  "CommitsSinceVersionSourcePadded":"0005",
  "CommitDate":"2019-11-16"
}

I agree that c6ab3b4eee5136be4e196d2fc974ddf5268e3fb1 as the VersionSourceSha seems a bit strange.

@asbjornu
Copy link
Member

If I add a tag to the HEAD of master, 651959ac5b7fafc9ee45faad3ea5db14135f5cb7 becomes the VersionSourceSha, but CommitsSinceVersionSource remains at 5, which is very strange:

$ git tag 12.0.0
$ gitversion
{
  "Major":12,
  "Minor":0,
  "Patch":0,
  "PreReleaseTag":"",
  "PreReleaseTagWithDash":"",
  "PreReleaseLabel":"",
  "PreReleaseNumber":"",
  "WeightedPreReleaseNumber":"",
  "BuildMetaData":"",
  "BuildMetaDataPadded":"",
  "FullBuildMetaData":"Branch.master.Sha.651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "MajorMinorPatch":"12.0.0",
  "SemVer":"12.0.0",
  "LegacySemVer":"12.0.0",
  "LegacySemVerPadded":"12.0.0",
  "AssemblySemVer":"12.0.0.0",
  "AssemblySemFileVer":"12.0.0.0",
  "FullSemVer":"12.0.0",
  "InformationalVersion":"12.0.0+Branch.master.Sha.651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "BranchName":"master",
  "Sha":"651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "ShortSha":"651959a",
  "NuGetVersionV2":"12.0.0",
  "NuGetVersion":"12.0.0",
  "NuGetPreReleaseTagV2":"",
  "NuGetPreReleaseTag":"",
  "VersionSourceSha":"651959ac5b7fafc9ee45faad3ea5db14135f5cb7",
  "CommitsSinceVersionSource":5,
  "CommitsSinceVersionSourcePadded":"0005",
  "CommitDate":"2019-11-16"
}

@asbjornu
Copy link
Member

There is something about version source that seems wonky. I'm not sure what, why or how to fix it.

@newegor
Copy link

newegor commented Mar 23, 2020

As I wrote before there is a difference in the way of merging branches in case of wrong and right behaviour of GitVersion. On the screenshot attached v12 is a wrong case, v11 is right one.
In v12 changes are merged from release branch to master and then from master to develop.
In v11 changes are merged from release branch to master and from release branch to deleop.
Sourcetree

@asbjornu
Copy link
Member

asbjornu commented Mar 23, 2020

Well, by that description v11 is the correct according to Gitflow and v12 is wrong, so perhaps the "wrong" version calculation for v12 is actually correct?

@newegor
Copy link

newegor commented Mar 23, 2020

v12 was done by official git flow extension so I think it's correct. v11 was done manually. Technically results for v11 and for v12 are the same, so the version also should be the same.

@asbjornu
Copy link
Member

asbjornu commented Mar 24, 2020

Which official Gitflow extension? From the descriptions of Gitflow I've read, release branches are merged to both master and develop:

Once the release is ready to ship, it will get merged it into master and develop, then the release branch will be deleted. It’s important to merge back into develop because critical updates may have been added to the release branch and they need to be accessible to new features. If your organization stresses code review, this would be an ideal place for a pull request.

Thus, a merge from master to develop should never happen.

@newegor
Copy link

newegor commented Mar 24, 2020

Please take a look to https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow and https://github.com/nvie/gitflow from the author of successful Git branching model

@asbjornu
Copy link
Member

Yes, @newegor, my quote is from that Atlassian article. I linked to it too. Here's a cheat sheet for git flow (the tool you're using) which also states that release branches should be merged to both develop and master:

Finish up a release

Finishing a release is one of the big steps in git branching. It performs several actions:

  • Merges the release branch back into 'master'
  • Tags the release with its name
  • Back-merges the release into 'develop'
  • Removes the release branch

I'm not using any tooling for Git flow, I just do the process manually, but I've never seen or read anywhere that the master branch should be merged back to develop.

@newegor
Copy link

newegor commented Mar 24, 2020

I use git-flow from command line (it simplifies this process for me a lot). The same git-flow extention is used inside SourceTree from Atlassian (same result from the history point of view). But anyway I'd like to point that the base for "CommitsSinceVersionSource" calculation is wrong in case of git-flow usage from command line or any GUI tool.

@asbjornu
Copy link
Member

Ok, thanks for the information, @newegor. I doubt this is going to be fixed unless anyone experiencing this problem provide a pull request. Consider this an open invitation to everyone commenting on this issue to submit a PR that fixes the problem. :)

@asbjornu
Copy link
Member

asbjornu commented Mar 27, 2020

Information provided in #2206 makes me believe that the implementation of gitflow has changed recently, which explains why this has suddently become a problem.

@stale
Copy link

stale bot commented Jun 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 25, 2020
@AlexEngblom
Copy link
Author

Information provided in #2206 makes me believe that the implementation of gitflow has changed recently, which explains why this has suddently become a problem.

Not sure how recently, but when I look back into our project it has been like this since the beginning (2018) when using SourceTree GitFlow tools. So bottom line is, that GitVersion does not support GitFlow currently?

And the problematic part in fixing this would be to support both approaches

  1. Merge release to master and development
  2. Merge release to master and then merge tag from master to development

@stale stale bot removed the stale label Jul 1, 2020
@asbjornu
Copy link
Member

asbjornu commented Jul 1, 2020

So bottom line is, that GitVersion does not support GitFlow currently?

In all documentation I've read on Git Flow, the tag occurs on master, not on the release/* branch. So saying GitVersion doesn't support Git Flow is obviously false.

Whether GitVersion is compatible with some tools implementation of Git Flow is a different question and it seems like some tools that have changed their behaviour are no longer compatible with GitVersion's implementation.

So yes, it's going to be hard to figure out how to solve this. It should be possible to detect the difference, it's just going to require a PR from someone who uses these Git Flow tools to fix it. I don't use tooling for Git Flow, so I don't have this problem, therefore I don't have much incentive to fix this myself. :)

@AlexEngblom
Copy link
Author

AlexEngblom commented Jul 2, 2020

@asbjornu you are correct. After delving into this, I'm baffled why these tools actually do it so different from the GitFlow documentation. Personally I've always resorted on these so the actual flow was unknown to me.

I also seem to actually get this with older GitVersion as well. The weird thing is that this happens at random, sometimes we get correct result and sometimes the source commit shifts. It looks like this is not actually an issue with the flow, but might have something to do with simultaneous commits.

Commits created (by SourceTree GitFlow tooling in our case) actually have the exact same timestamp as per example below. Even 'git log' outputs them in the wrong order here. This seems to repro with the tool almost consistently if I create the release with no additional direct commits on the release branch itself.

image

Git log (default descending order):

commit f477d3350e90f4968729d1df4a69ddc35c19986a (tag: 1.6.0)
Merge: 30389bf 55b7c43
Author: Anonymous
Date:   Mon Mar 2 17:39:50 2020 +0200

    Merge branch 'release/1.6.0'

commit a4b3860f18a87c4b08c98a440cd94a21b7a69ff8
Merge: 55b7c43 f477d33
Author: Anonymous
Date:   Mon Mar 2 17:39:50 2020 +0200

    Merge tag '1.6.0' into development

    1.6.0

This could cause issues in this block of code, if the order of commits resolved from injection may have variaton.

BaseVersionCalculator.cs

if (matchingVersionsOnceIncremented.Any())
{
    var oldest = matchingVersionsOnceIncremented.Aggregate((v1, v2) => v1.Version.BaseVersionSource.Committer.When < v2.Version.BaseVersionSource.Committer.When ? v1 : v2);
    baseVersionWithOldestSource = oldest.Version;
    maxVersion = oldest;
    log.Info($"Found multiple base versions which will produce the same SemVer ({maxVersion.IncrementedVersion}), taking oldest source for commit counting ({baseVersionWithOldestSource.Source})");
}

I tried to repro this as unit test, but it will take more time with my non-existent knowledge of GitVersion codebase. Hopefully I can come back with this later. I suppose we would then need to implement some (uglyish) sniffing logic and make assumptions on the order of things to be consistent with the VersionSourceSha. Dunno 😵

Any thoughts on this?

@asbjornu
Copy link
Member

asbjornu commented Jul 2, 2020

Thanks for the investigation, @AlexEngblom! If you are able to reproduce this in a physical Git repository (it seems like you are) and it proves hard to replicate the problem in a RepositoryFixture test, we might consider setting up a physical reproduction repository in GitVersion.TestCases.

@stale
Copy link

stale bot commented Oct 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@asbjornu
Copy link
Member

asbjornu commented Mar 8, 2022

This issue is revived in #2394.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants