-
Paul Irish committed 6 years ago1 parent 7449bfa7
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
-
1 + #!/usr/bin/env bats 2 + 3 + load "test_helper/index" 4 + 5 + ## 6 + ## Bitbucket 7 + ## 8 + 9 + @test "bitbucket: basic" { 10 + git remote set-url origin "[email protected]:paulirish/crbug-extension.git" 11 + run ../git-open 12 + assert_output --partial "https://bitbucket.org/paulirish/crbug-extension" 13 + } 14 + 15 + @test "bitbucket: non-origin remote" { 16 + # https://github.com/paulirish/git-open/pull/4 17 + git remote add bbclone "[email protected]:rwhitbeck/git-open.git" 18 + run ../git-open "bbclone" 19 + assert_output "https://bitbucket.org/rwhitbeck/git-open" 20 + } 21 + 22 + @test "bitbucket: open source view" { 23 + # https://github.com/paulirish/git-open/pull/26 24 + git remote set-url origin "https://bitbucket.org/kisom/consbri.git" 25 + git checkout -B "devel" 26 + run ../git-open 27 + refute_output --partial "//kisom" 28 + assert_output "https://bitbucket.org/kisom/consbri/src?at=devel" 29 + } 30 + 31 + @test "bitbucket: open source view with a slash/branch" { 32 + # https://github.com/paulirish/git-open/pull/26 33 + # see https://github.com/paulirish/git-open/issues/80 for feat/branchname issues 34 + git remote set-url origin "https://bitbucket.org/guyzmo/git-repo.git" 35 + git checkout -B "bugfix/conftest_fix" 36 + run ../git-open 37 + assert_output --partial "https://bitbucket.org/guyzmo/git-repo/src" 38 + # BB appears to be fine with both literal or URL-encoded forward slash 39 + assert_output --partial "?at=bugfix/conftest_fix" 40 + } 41 + 42 + @test "bitbucket: ssh:// clone urls" { 43 + # https://github.com/paulirish/git-open/pull/36 44 + git remote set-url origin "ssh://[email protected]/lbesson/bin.git" 45 + run ../git-open 46 + assert_output "https://bitbucket.org/lbesson/bin" 47 + } 48 + 49 + @test "bitbucket: no username@ in final url" { 50 + # https://github.com/paulirish/git-open/pull/69 51 + git remote set-url origin "https://[email protected]/trend_rand/test-repo.git" 52 + run ../git-open 53 + refute_output --partial "@" 54 + } 55 + 56 + @test "bitbucket: Bitbucket Server" { 57 + # https://github.com/paulirish/git-open/issues/77#issuecomment-309044010 58 + git remote set-url origin "https://[email protected]/scm/ppp/rrr.git" 59 + run ../git-open 60 + 61 + # any of the following are acceptable 62 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr" || 63 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=master" || 64 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=refs%2Fheads%2Fmaster" 65 + } 66 + 67 + @test "bitbucket: Bitbucket Server branch" { 68 + # https://github.com/paulirish/git-open/issues/80 69 + git remote set-url origin "https://[email protected]/scm/ppp/rrr.git" 70 + git checkout -B "develop" 71 + run ../git-open 72 + 73 + # The following query args work with BB Server: 74 + # at=refs%2Fheads%2Fdevelop, at=develop, at=refs/heads/develop 75 + # However /src/develop does not (unlike bitbucket.org) 76 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=develop" || 77 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 78 + assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs/heads/develop" 79 + 80 + refute_output --partial "/src/develop" 81 + } 82 + 83 + 84 + @test "bitbucket: Bitbucket Server private user repos" { 85 + # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538 86 + git remote set-url origin "https://mybb.domain.com/scm/~first.last/rrr.git" 87 + git checkout -B "develop" 88 + run ../git-open 89 + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=develop" || 90 + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 91 + assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs/heads/develop" 92 + 93 + } 94 + 95 + 96 + @test "bitbucket: Bitbucket Server with different root context" { 97 + # https://github.com/paulirish/git-open/pull/15 98 + git remote set-url origin "https://[email protected]/git/scm/ppp/test-repo.git" 99 + run ../git-open 100 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo" || 101 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=master" || 102 + assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster" 103 + } 104 + 105 + 106 + @test "bitbucket: Bitbucket Server with different root context with multiple parts" { 107 + # https://github.com/paulirish/git-open/pull/15 108 + git remote set-url origin "https://[email protected]/really/long/root/context/scm/ppp/test-repo.git" 109 + run ../git-open 110 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo" || 111 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=master" || 112 + assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster" 113 + } 114 + 115 + 116 + @test "bitbucket: Bitbucket Server private user repos with different root context" { 117 + # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538 118 + git remote set-url origin "https://mybb.domain.com/root/context/scm/~first.last/rrr.git" 119 + git checkout -B "develop" 120 + run ../git-open 121 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=develop" || 122 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 123 + assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs/heads/develop" 124 + } 125 + -
1 1 #!/usr/bin/env bats 2 2 3 - load "test_helper/bats-support/load" 4 - load "test_helper/bats-assert/load" 5 - 6 - foldername="sandboxrepo" 7 - 8 - setup() { 9 - create_git_sandbox 10 - export BROWSER=echo 11 - } 3 + load "test_helper/index" 12 4 13 5 ## 14 6 ## Test environment skipped 32 lines 47 39 assert_output "http://example.com/example" 48 40 } 49 41 50 - ## 51 - ## GitHub 52 - ## 53 42 54 - @test "gh: basic" { 55 - git remote set-url origin "[email protected]:user/repo.git" 56 - git checkout -B "master" 57 - run ../git-open 58 - assert_output "https://github.com/user/repo" 59 - } 60 - 61 - @test "gh: branch" { 62 - git remote set-url origin "[email protected]:user/repo.git" 63 - git checkout -B "mybranch" 64 - run ../git-open 65 - assert_output "https://github.com/user/repo/tree/mybranch" 66 - } 67 - 68 - @test "gh: non-origin remote" { 69 - git remote set-url origin "[email protected]:user/repo.git" 70 - git remote add upstream "[email protected]:upstreamorg/repo.git" 71 - run ../git-open "upstream" 72 - assert_output "https://github.com/upstreamorg/repo" 73 - 74 - git checkout -B "mybranch" 75 - run ../git-open "upstream" "otherbranch" 76 - assert_output "https://github.com/upstreamorg/repo/tree/otherbranch" 77 - } 78 - 79 - @test "gh: without git user" { 80 - # https://github.com/paulirish/git-open/pull/63 81 - git remote set-url origin "github.com:paulirish/git-open.git" 82 - run ../git-open 83 - assert_output "https://github.com/paulirish/git-open" 84 - } 85 - 86 - @test "gh: ssh origin" { 87 - git remote set-url origin "ssh://[email protected]/user/repo" 88 - run ../git-open 89 - assert_output "https://github.com/user/repo" 90 - 91 - # https://github.com/paulirish/git-open/pull/30 92 - git remote set-url origin "ssh://[email protected]/user/repo.git" 93 - run ../git-open 94 - assert_output "https://github.com/user/repo" 95 - } 96 - 97 - @test "gh: git protocol origin" { 98 - git remote set-url origin "git://github.com/user/repo.git" 99 - git checkout -B "master" 100 - run ../git-open 101 - assert_output "https://github.com/user/repo" 102 - } 103 - 104 - @test "gh: git open --issue" { 105 - # https://github.com/paulirish/git-open/pull/46 106 - git remote set-url origin "github.com:paulirish/git-open.git" 107 - git checkout -B "issues/#12" 108 - run ../git-open "--issue" 109 - assert_output "https://github.com/paulirish/git-open/issues/12" 110 - 111 - git checkout -B "fix-issue-37" 112 - run ../git-open "--issue" 113 - assert_output "https://github.com/paulirish/git-open/issues/37" 114 - 115 - git checkout -B "fix-issue-38" 116 - run ../git-open "-i" 117 - assert_output "https://github.com/paulirish/git-open/issues/38" 118 - } 119 - 120 - @test "gh: gist" { 121 - git remote set-url origin "[email protected]:2d84a6db1b41b4020685.git" 122 - run ../git-open 123 - assert_output "https://gist.github.com/2d84a6db1b41b4020685" 124 - } 125 - 126 - @test "basic: # and % in branch names are URL encoded" { 127 - # https://github.com/paulirish/git-open/pull/24 128 - git checkout -B "issue-#42" 129 - run ../git-open 130 - assert_output "https://github.com/paulirish/git-open/tree/issue-%2342" 131 - 132 - git checkout -B "just-50%" 133 - run ../git-open 134 - assert_output "https://github.com/paulirish/git-open/tree/just-50%25" 135 - } 136 - 137 - @test "basic: tracked remote is default" { 138 - # https://github.com/paulirish/git-open/issues/65 139 - 140 - # create a local git repo I can push to 141 - remote_name="sandboxremote" 142 - remote_url="[email protected]:userfork/git-open.git" 143 - 144 - # ideally we'd set a real upstream branch, but that's not possible without 145 - # pull/push'ing over the network. So we're cheating and just setting the 146 - # branch.<branch>.remote config 147 - # https://github.com/paulirish/git-open/pull/88#issuecomment-339813145 148 - git remote add $remote_name $remote_url 149 - git config --local --add branch.master.remote $remote_name 150 - 151 - run ../git-open 152 - assert_output "https://github.com/userfork/git-open" 153 - 154 - git config --local --add branch.master.remote origin 155 - run ../git-open 156 - assert_output "https://github.com/paulirish/git-open" 157 - } 158 - 159 - @test "basic: https url can contain port" { 160 - git remote set-url origin "https://github.com:99/user/repo.git" 161 - run ../git-open 162 - assert_output "https://github.com:99/user/repo" 163 - } 164 - 165 - @test "basic: ssh url has port removed from http url" { 166 - git remote set-url origin "ssh://github.com:22/user/repo.git" 167 - run ../git-open 168 - assert_output "https://github.com/user/repo" 169 - } 170 - 171 - @test "basic: http url scheme is preserved" { 172 - git remote set-url origin "http://github.com/user/repo.git" 173 - run ../git-open 174 - assert_output "http://github.com/user/repo" 175 - } 176 - 177 - 178 - ## 179 - ## Bitbucket 180 - ## 181 - 182 - @test "bitbucket: basic" { 183 - git remote set-url origin "[email protected]:paulirish/crbug-extension.git" 184 - run ../git-open 185 - assert_output --partial "https://bitbucket.org/paulirish/crbug-extension" 186 - } 187 - 188 - @test "bitbucket: non-origin remote" { 189 - # https://github.com/paulirish/git-open/pull/4 190 - git remote add bbclone "[email protected]:rwhitbeck/git-open.git" 191 - run ../git-open "bbclone" 192 - assert_output "https://bitbucket.org/rwhitbeck/git-open" 193 - } 194 - 195 - @test "bitbucket: open source view" { 196 - # https://github.com/paulirish/git-open/pull/26 197 - git remote set-url origin "https://bitbucket.org/kisom/consbri.git" 198 - git checkout -B "devel" 199 - run ../git-open 200 - refute_output --partial "//kisom" 201 - assert_output "https://bitbucket.org/kisom/consbri/src?at=devel" 202 - } 203 - 204 - @test "bitbucket: open source view with a slash/branch" { 205 - # https://github.com/paulirish/git-open/pull/26 206 - # see https://github.com/paulirish/git-open/issues/80 for feat/branchname issues 207 - git remote set-url origin "https://bitbucket.org/guyzmo/git-repo.git" 208 - git checkout -B "bugfix/conftest_fix" 209 - run ../git-open 210 - assert_output --partial "https://bitbucket.org/guyzmo/git-repo/src" 211 - # BB appears to be fine with both literal or URL-encoded forward slash 212 - assert_output --partial "?at=bugfix/conftest_fix" 213 - } 214 - 215 - @test "bitbucket: ssh:// clone urls" { 216 - # https://github.com/paulirish/git-open/pull/36 217 - git remote set-url origin "ssh://[email protected]/lbesson/bin.git" 218 - run ../git-open 219 - assert_output "https://bitbucket.org/lbesson/bin" 220 - } 221 - 222 - @test "bitbucket: no username@ in final url" { 223 - # https://github.com/paulirish/git-open/pull/69 224 - git remote set-url origin "https://[email protected]/trend_rand/test-repo.git" 225 - run ../git-open 226 - refute_output --partial "@" 227 - } 228 - 229 - @test "bitbucket: Bitbucket Server" { 230 - # https://github.com/paulirish/git-open/issues/77#issuecomment-309044010 231 - git remote set-url origin "https://[email protected]/scm/ppp/rrr.git" 232 - run ../git-open 233 - 234 - # any of the following are acceptable 235 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr" || 236 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=master" || 237 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse/?at=refs%2Fheads%2Fmaster" 238 - } 239 - 240 - @test "bitbucket: Bitbucket Server branch" { 241 - # https://github.com/paulirish/git-open/issues/80 242 - git remote set-url origin "https://[email protected]/scm/ppp/rrr.git" 243 - git checkout -B "develop" 244 - run ../git-open 245 - 246 - # The following query args work with BB Server: 247 - # at=refs%2Fheads%2Fdevelop, at=develop, at=refs/heads/develop 248 - # However /src/develop does not (unlike bitbucket.org) 249 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=develop" || 250 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 251 - assert_output "https://mybb.domain.com/projects/ppp/repos/rrr/browse?at=refs/heads/develop" 252 - 253 - refute_output --partial "/src/develop" 254 - } 255 - 256 - 257 - @test "bitbucket: Bitbucket Server private user repos" { 258 - # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538 259 - git remote set-url origin "https://mybb.domain.com/scm/~first.last/rrr.git" 260 - git checkout -B "develop" 261 - run ../git-open 262 - assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=develop" || 263 - assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 264 - assert_output "https://mybb.domain.com/projects/~first.last/repos/rrr/browse?at=refs/heads/develop" 265 - 266 - } 267 - 268 - 269 - @test "bitbucket: Bitbucket Server with different root context" { 270 - # https://github.com/paulirish/git-open/pull/15 271 - git remote set-url origin "https://[email protected]/git/scm/ppp/test-repo.git" 272 - run ../git-open 273 - assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo" || 274 - assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=master" || 275 - assert_output "https://bitbucket.example.com/git/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster" 276 - } 277 - 278 - 279 - @test "bitbucket: Bitbucket Server with different root context with multiple parts" { 280 - # https://github.com/paulirish/git-open/pull/15 281 - git remote set-url origin "https://[email protected]/really/long/root/context/scm/ppp/test-repo.git" 282 - run ../git-open 283 - assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo" || 284 - assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=master" || 285 - assert_output "https://bitbucket.example.com/really/long/root/context/projects/ppp/repos/test-repo/?at=refs%2Fheads%2Fmaster" 286 - } 287 - 288 - 289 - @test "bitbucket: Bitbucket Server private user repos with different root context" { 290 - # https://github.com/paulirish/git-open/pull/83#issuecomment-309968538 291 - git remote set-url origin "https://mybb.domain.com/root/context/scm/~first.last/rrr.git" 292 - git checkout -B "develop" 293 - run ../git-open 294 - assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=develop" || 295 - assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs%2Fheads%2Fdevelop" || 296 - assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs/heads/develop" 297 - } 298 - 299 - 300 - ## 301 - ## GitLab 302 - ## 303 - 304 - @test "gitlab: default ssh origin style" { 305 - # https://github.com/paulirish/git-open/pull/55 306 - git remote set-url origin "[email protected]:user/repo" 307 - run ../git-open 308 - assert_output "https://gitlab.example.com/user/repo" 309 - } 310 - 311 - @test "gitlab: ssh://git@ origin" { 312 - # https://github.com/paulirish/git-open/pull/51 313 - git remote set-url origin "ssh://[email protected]/user/repo" 314 - run ../git-open 315 - assert_output "https://gitlab.domain.com/user/repo" 316 - refute_output --partial "//user" 317 - } 318 - 319 - @test "gitlab: separate domains" { 320 - # https://github.com/paulirish/git-open/pull/56 321 - git remote set-url origin "[email protected]:namespace/project.git" 322 - git config --local --add "open.https://git.example.com.domain" "gitlab.example.com" 323 - run ../git-open 324 - assert_output "https://gitlab.example.com/namespace/project" 325 - } 326 - 327 - @test "gitlab: special domain and path" { 328 - git remote set-url origin "ssh://[email protected]:7000/XXX/YYY.git" 329 - git config --local --add "open.https://git.example.com.domain" "repo.intranet/subpath" 330 - git config --local --add "open.https://git.example.com.protocol" "http" 331 - 332 - run ../git-open 333 - assert_output "http://repo.intranet/subpath/XXX/YYY" 334 - refute_output --partial "https://" 335 - } 336 - 337 - @test "gitlab: different port" { 338 - # https://github.com/paulirish/git-open/pull/76 339 - git remote set-url origin "ssh://[email protected]:7000/XXX/YYY.git" 340 - run ../git-open 341 - assert_output "https://git.example.com/XXX/YYY" 342 - refute_output --partial ":7000" 343 - 344 - git remote set-url origin "https://git.example.com:7000/XXX/YYY.git" 345 - run ../git-open 346 - assert_output "https://git.example.com:7000/XXX/YYY" 347 - } 348 - 349 - ## 350 - ## Visual Studio Team Services 351 - ## 352 - 353 - @test "vsts: https url" { 354 - git remote set-url origin "https://gitopen.visualstudio.com/Project/_git/Repository" 355 - run ../git-open 356 - assert_output --partial "https://gitopen.visualstudio.com/Project/_git/Repository" 357 - } 358 - 359 - @test "vsts: ssh url" { 360 - git remote add vsts_ssh "ssh://[email protected]:22/Project/_git/Repository" 361 - run ../git-open "vsts_ssh" 362 - assert_output "https://gitopen.visualstudio.com/Project/_git/Repository" 363 - } 364 - 365 - @test "vsts: on-premises tfs http url" { 366 - git remote set-url origin "http://tfs.example.com:8080/Project/_git/Repository" 367 - run ../git-open 368 - assert_output --partial "http://tfs.example.com:8080/Project/_git/Repository" 369 - } 370 - 371 - @test "vsts: branch" { 372 - git remote set-url origin "ssh://[email protected]:22/_git/Repository" 373 - git checkout -B "mybranch" 374 - run ../git-open 375 - assert_output "https://gitopen.visualstudio.com/_git/Repository?version=GBmybranch" 376 - } 377 - 378 - @test "vsts: on-premises tfs branch" { 379 - git remote set-url origin "http://tfs.example.com:8080/Project/Folder/_git/Repository" 380 - git checkout -B "mybranch" 381 - run ../git-open 382 - assert_output "http://tfs.example.com:8080/Project/Folder/_git/Repository?version=GBmybranch" 383 - } 384 - 385 - @test "vsts: issue" { 386 - git remote set-url origin "http://tfs.example.com:8080/Project/Folder/_git/Repository" 387 - git checkout -B "bugfix-36" 388 - run ../git-open "--issue" 389 - assert_output "http://tfs.example.com:8080/Project/Folder/_workitems?id=36" 390 - } 391 - 392 - 393 - teardown() { 394 - cd .. 395 - rm -rf "$foldername" 396 - } 397 - 398 - # helper to create a test git sandbox that won't dirty the real repo 399 - function create_git_sandbox() { 400 - rm -rf "$foldername" 401 - mkdir "$foldername" 402 - cd "$foldername" 403 - # safety check. Don't muck with the git repo if we're not inside the sandbox. 404 - assert_equal $(basename $PWD) "$foldername" 405 - 406 - git init -q 407 - assert [ -e "../$foldername/.git" ] 408 - git config user.email "[email protected]" && git config user.name "Test Runner" 409 - 410 - # newer git auto-creates the origin remote 411 - if ! git remote add origin "github.com:paulirish/git-open.git"; then 412 - git remote set-url origin "github.com:paulirish/git-open.git" 413 - fi 414 - 415 - git checkout -B "master" 416 - 417 - echo "ok" > readme.txt 418 - git add readme.txt 419 - git commit -m "add file" -q 420 - } 421 43 -
1 + #!/usr/bin/env bats 2 + 3 + load "test_helper/index" 4 + 5 + ## 6 + ## GitHub 7 + ## 8 + 9 + @test "gh: basic" { 10 + git remote set-url origin "[email protected]:user/repo.git" 11 + git checkout -B "master" 12 + run ../git-open 13 + assert_output "https://github.com/user/repo" 14 + } 15 + 16 + @test "gh: branch" { 17 + git remote set-url origin "[email protected]:user/repo.git" 18 + git checkout -B "mybranch" 19 + run ../git-open 20 + assert_output "https://github.com/user/repo/tree/mybranch" 21 + } 22 + 23 + @test "gh: non-origin remote" { 24 + git remote set-url origin "[email protected]:user/repo.git" 25 + git remote add upstream "[email protected]:upstreamorg/repo.git" 26 + run ../git-open "upstream" 27 + assert_output "https://github.com/upstreamorg/repo" 28 + 29 + git checkout -B "mybranch" 30 + run ../git-open "upstream" "otherbranch" 31 + assert_output "https://github.com/upstreamorg/repo/tree/otherbranch" 32 + } 33 + 34 + @test "gh: without git user" { 35 + # https://github.com/paulirish/git-open/pull/63 36 + git remote set-url origin "github.com:paulirish/git-open.git" 37 + run ../git-open 38 + assert_output "https://github.com/paulirish/git-open" 39 + } 40 + 41 + @test "gh: ssh origin" { 42 + git remote set-url origin "ssh://[email protected]/user/repo" 43 + run ../git-open 44 + assert_output "https://github.com/user/repo" 45 + 46 + # https://github.com/paulirish/git-open/pull/30 47 + git remote set-url origin "ssh://[email protected]/user/repo.git" 48 + run ../git-open 49 + assert_output "https://github.com/user/repo" 50 + } 51 + 52 + @test "gh: git protocol origin" { 53 + git remote set-url origin "git://github.com/user/repo.git" 54 + git checkout -B "master" 55 + run ../git-open 56 + assert_output "https://github.com/user/repo" 57 + } 58 + 59 + @test "gh: git open --issue" { 60 + # https://github.com/paulirish/git-open/pull/46 61 + git remote set-url origin "github.com:paulirish/git-open.git" 62 + git checkout -B "issues/#12" 63 + run ../git-open "--issue" 64 + assert_output "https://github.com/paulirish/git-open/issues/12" 65 + 66 + git checkout -B "fix-issue-37" 67 + run ../git-open "--issue" 68 + assert_output "https://github.com/paulirish/git-open/issues/37" 69 + 70 + git checkout -B "fix-issue-38" 71 + run ../git-open "-i" 72 + assert_output "https://github.com/paulirish/git-open/issues/38" 73 + } 74 + 75 + @test "gh: gist" { 76 + git remote set-url origin "[email protected]:2d84a6db1b41b4020685.git" 77 + run ../git-open 78 + assert_output "https://gist.github.com/2d84a6db1b41b4020685" 79 + } 80 + 81 + @test "basic: # and % in branch names are URL encoded" { 82 + # https://github.com/paulirish/git-open/pull/24 83 + git checkout -B "issue-#42" 84 + run ../git-open 85 + assert_output "https://github.com/paulirish/git-open/tree/issue-%2342" 86 + 87 + git checkout -B "just-50%" 88 + run ../git-open 89 + assert_output "https://github.com/paulirish/git-open/tree/just-50%25" 90 + } 91 + 92 + @test "basic: tracked remote is default" { 93 + # https://github.com/paulirish/git-open/issues/65 94 + 95 + # create a local git repo I can push to 96 + remote_name="sandboxremote" 97 + remote_url="[email protected]:userfork/git-open.git" 98 + 99 + # ideally we'd set a real upstream branch, but that's not possible without 100 + # pull/push'ing over the network. So we're cheating and just setting the 101 + # branch.<branch>.remote config 102 + # https://github.com/paulirish/git-open/pull/88#issuecomment-339813145 103 + git remote add $remote_name $remote_url 104 + git config --local --add branch.master.remote $remote_name 105 + 106 + run ../git-open 107 + assert_output "https://github.com/userfork/git-open" 108 + 109 + git config --local --add branch.master.remote origin 110 + run ../git-open 111 + assert_output "https://github.com/paulirish/git-open" 112 + } 113 + 114 + @test "basic: https url can contain port" { 115 + git remote set-url origin "https://github.com:99/user/repo.git" 116 + run ../git-open 117 + assert_output "https://github.com:99/user/repo" 118 + } 119 + 120 + @test "basic: ssh url has port removed from http url" { 121 + git remote set-url origin "ssh://github.com:22/user/repo.git" 122 + run ../git-open 123 + assert_output "https://github.com/user/repo" 124 + } 125 + 126 + @test "basic: http url scheme is preserved" { 127 + git remote set-url origin "http://github.com/user/repo.git" 128 + run ../git-open 129 + assert_output "http://github.com/user/repo" 130 + } 131 + 132 + -
1 + #!/usr/bin/env bats 2 + 3 + load "test_helper/index" 4 + 5 + ## 6 + ## GitLab 7 + ## 8 + 9 + @test "gitlab: default ssh origin style" { 10 + # https://github.com/paulirish/git-open/pull/55 11 + git remote set-url origin "[email protected]:user/repo" 12 + run ../git-open 13 + assert_output "https://gitlab.example.com/user/repo" 14 + } 15 + 16 + @test "gitlab: ssh://git@ origin" { 17 + # https://github.com/paulirish/git-open/pull/51 18 + git remote set-url origin "ssh://[email protected]/user/repo" 19 + run ../git-open 20 + assert_output "https://gitlab.domain.com/user/repo" 21 + refute_output --partial "//user" 22 + } 23 + 24 + @test "gitlab: separate domains" { 25 + # https://github.com/paulirish/git-open/pull/56 26 + git remote set-url origin "[email protected]:namespace/project.git" 27 + git config --local --add "open.https://git.example.com.domain" "gitlab.example.com" 28 + run ../git-open 29 + assert_output "https://gitlab.example.com/namespace/project" 30 + } 31 + 32 + @test "gitlab: special domain and path" { 33 + git remote set-url origin "ssh://[email protected]:7000/XXX/YYY.git" 34 + git config --local --add "open.https://git.example.com.domain" "repo.intranet/subpath" 35 + git config --local --add "open.https://git.example.com.protocol" "http" 36 + 37 + run ../git-open 38 + assert_output "http://repo.intranet/subpath/XXX/YYY" 39 + refute_output --partial "https://" 40 + } 41 + 42 + @test "gitlab: different port" { 43 + # https://github.com/paulirish/git-open/pull/76 44 + git remote set-url origin "ssh://[email protected]:7000/XXX/YYY.git" 45 + run ../git-open 46 + assert_output "https://git.example.com/XXX/YYY" 47 + refute_output --partial ":7000" 48 + 49 + git remote set-url origin "https://git.example.com:7000/XXX/YYY.git" 50 + run ../git-open 51 + assert_output "https://git.example.com:7000/XXX/YYY" 52 + } 53 + 54 + -
1 + #!/usr/bin/env bats 2 + 3 + load "test_helper/bats-support/load" 4 + load "test_helper/bats-assert/load" 5 + 6 + foldername="sandboxrepo" 7 + 8 + setup() { 9 + create_git_sandbox 10 + export BROWSER=echo 11 + } 12 + 13 + teardown() { 14 + cd .. 15 + rm -rf "$foldername" 16 + } 17 + 18 + # helper to create a test git sandbox that won't dirty the real repo 19 + function create_git_sandbox() { 20 + rm -rf "$foldername" 21 + mkdir "$foldername" 22 + cd "$foldername" 23 + # safety check. Don't muck with the git repo if we're not inside the sandbox. 24 + assert_equal $(basename $PWD) "$foldername" 25 + 26 + git init -q 27 + assert [ -e "../$foldername/.git" ] 28 + git config user.email "[email protected]" && git config user.name "Test Runner" 29 + 30 + # newer git auto-creates the origin remote 31 + if ! git remote add origin "github.com:paulirish/git-open.git"; then 32 + git remote set-url origin "github.com:paulirish/git-open.git" 33 + fi 34 + 35 + git checkout -B "master" 36 + 37 + echo "ok" > readme.txt 38 + git add readme.txt 39 + git commit -m "add file" -q 40 + } 41 + -
1 + #!/usr/bin/env bats 2 + 3 + load "test_helper/index" 4 + 5 + ## 6 + ## Visual Studio Team Services 7 + ## 8 + 9 + @test "vsts: https url" { 10 + git remote set-url origin "https://gitopen.visualstudio.com/Project/_git/Repository" 11 + run ../git-open 12 + assert_output --partial "https://gitopen.visualstudio.com/Project/_git/Repository" 13 + } 14 + 15 + @test "vsts: ssh url" { 16 + git remote add vsts_ssh "ssh://[email protected]:22/Project/_git/Repository" 17 + run ../git-open "vsts_ssh" 18 + assert_output "https://gitopen.visualstudio.com/Project/_git/Repository" 19 + } 20 + 21 + @test "vsts: on-premises tfs http url" { 22 + git remote set-url origin "http://tfs.example.com:8080/Project/_git/Repository" 23 + run ../git-open 24 + assert_output --partial "http://tfs.example.com:8080/Project/_git/Repository" 25 + } 26 + 27 + @test "vsts: branch" { 28 + git remote set-url origin "ssh://[email protected]:22/_git/Repository" 29 + git checkout -B "mybranch" 30 + run ../git-open 31 + assert_output "https://gitopen.visualstudio.com/_git/Repository?version=GBmybranch" 32 + } 33 + 34 + @test "vsts: on-premises tfs branch" { 35 + git remote set-url origin "http://tfs.example.com:8080/Project/Folder/_git/Repository" 36 + git checkout -B "mybranch" 37 + run ../git-open 38 + assert_output "http://tfs.example.com:8080/Project/Folder/_git/Repository?version=GBmybranch" 39 + } 40 + 41 + @test "vsts: issue" { 42 + git remote set-url origin "http://tfs.example.com:8080/Project/Folder/_git/Repository" 43 + git checkout -B "bugfix-36" 44 + run ../git-open "--issue" 45 + assert_output "http://tfs.example.com:8080/Project/Folder/_workitems?id=36" 46 + } 47 + 48 +