Projects STRLCPY git-open Commits beebcdbf
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    git-open
    skipped 125 lines
    126 126  if [[ "$domain" == 'bitbucket.org' ]]; then
    127 127   # Bitbucket, see https://github.com/paulirish/git-open/issues/80 for why ?at is needed.
    128 128   providerBranchRef="/src?at=$branch"
    129  -elif [[ ${pathargs[0]} == 'scm' ]]; then
    130  - # Bitbucket server, which starts with 'scm'
    131  - # Replace the first element, 'scm', with 'projects'. Keep the first argument, the string 'repos', and finally the rest of the arguments.
    132  - pathargs=('projects' ${pathargs[1]} 'repos' "${pathargs[@]:2}")
     129 +elif [[ "${#pathargs[@]}" -ge 3 && ${pathargs[${#pathargs[@]} - 3]} == 'scm' ]]; then
     130 + # Bitbucket server always has /scm/ as the third to last segment in the url path, e.g. /scm/ppp/test-repo.git
     131 + # Anything before the 'scm' is part of the server's root context
     132 + 
     133 + # If there are other context parts, add them, up to (but not including) the found 'scm'
     134 + pathPref=("${pathargs[*]:0:${#pathargs[@]} - 3}")
     135 + 
     136 + # Replace the 'scm' element, with 'projects'. Keep the first argument, the string 'repos', and finally the rest of the arguments.
     137 + pathargs=(${pathPref[@]} 'projects' ${pathargs[${#pathargs[@]} - 2]} 'repos' "${pathargs[@]:${#pathargs[@]} - 1}")
    133 138   IFS='/' urlpath="${pathargs[*]}"
    134 139   providerBranchRef="/browse?at=$branch"
    135 140  elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' ]]; then
    skipped 43 lines
  • ■ ■ ■ ■ ■ ■
    test/git-open.bats
    skipped 213 lines
    214 214   refute_output --partial "@"
    215 215  }
    216 216   
    217  -@test "bitbucket server" {
    218  - # https://github.com/paulirish/git-open/pull/15
    219  - git remote set-url origin "https://[email protected]/scm/ppp/test-repo.git"
    220  - run ../git-open
    221  - assert_output "https://bitbucket.example.com/projects/ppp/repos/test-repo"
    222  -}
    223  - 
    224  -@test "bitbucket server branch" {
    225  - # https://github.com/paulirish/git-open/pull/15
    226  - git remote set-url origin "https://[email protected]/scm/ppp/test-repo.git"
    227  - git checkout -B "bb-server"
    228  - run ../git-open
    229  - assert_output "https://bitbucket.example.com/projects/ppp/repos/test-repo/browse?at=bb-server"
    230  -}
    231  - 
    232  - 
    233 217  @test "bitbucket: Bitbucket Server" {
    234 218   # https://github.com/paulirish/git-open/issues/77#issuecomment-309044010
    235 219   git remote set-url origin "https://[email protected]/scm/ppp/rrr.git"
    skipped 32 lines
    268 252   assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs/heads/develop"
    269 253   
    270 254  }
     255 + 
     256 + 
     257 +@test "bitbucket: Bitbucket Server with different root context" {
     258 + # https://github.com/paulirish/git-open/pull/15
     259 + git remote set-url origin "https://[email protected]/git/scm/ppp/test-repo.git"
     260 + run ../git-open
     261 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo" ||
     262 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=master" ||
     263 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster"
     264 +}
     265 + 
     266 + 
     267 +@test "bitbucket: Bitbucket Server with different root context with multiple parts" {
     268 + # https://github.com/paulirish/git-open/pull/15
     269 + git remote set-url origin "https://[email protected]/really/long/root/context/scm/ppp/test-repo.git"
     270 + run ../git-open
     271 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo" ||
     272 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=master" ||
     273 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster"
     274 +}
     275 + 
     276 + 
     277 +@test "bitbucket: Bitbucket Server private user repos with different root context" {
     278 + # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538
     279 + git remote set-url origin "https://mybb.domain.com/root/context/scm/~first.last/rrr.git"
     280 + git checkout -B "develop"
     281 + run ../git-open
     282 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=develop" ||
     283 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" ||
     284 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs/heads/develop"
     285 +}
     286 + 
    271 287   
    272 288  ##
    273 289  ## GitLab
    skipped 120 lines
Please wait...
Page is in error, reload to recover