From 0f5ba78978ff081ec761e848553085c078c1c73f Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 9 May 2010 15:23:51 -0400 Subject: [PATCH] Consolidated duplicated support files created by automatic TM bundle conversion. --- Contents/Info.plist | 30 ++-- .../add_to_multifile_gist} | 0 .../annotate_blame_comment_line} | 0 .../create_gist_from_selection} | 0 .../create_private_gist_from_selection} | 0 .../send_multifile_gist} | 0 .../send_private_multifile_gist} | 0 .../show_in_github} | 0 .../{script => show_network_in_github} | 0 .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- .../bin/add_to_multifile_gist.rb | 6 - .../Support Files/bin/comment_on_line.rb | 22 --- .../bin/create_gist_from_selection.rb | 8 -- .../Support Files/bin/send_multifile_gist.rb | 6 - .../Support Files/bin/show_in_github.rb | 15 -- .../bin/show_network_in_github.rb | 16 --- .../Support Files/lib/gist.rb | 129 ----------------- .../Support Files/lib/git-ext/commit.rb | 6 - .../Support Files/lib/git_manager.rb | 131 ------------------ .../Support Files/lib/show_in_github.rb | 30 ---- .../Support Files/lib/tmp_gists | Bin 5 -> 0 bytes .../Support Files/test/test_git_manager.rb | 34 ----- .../test/test_git_object_commit.rb | 22 --- .../Support Files/test/test_helper.rb | 15 -- .../Support Files/test/test_show_in_github.rb | 84 ----------- .../test_show_line_in_commit_in_github.rb | 51 ------- 121 files changed, 15 insertions(+), 4040 deletions(-) rename Contents/Resources/{51A5A6E5-7A54-4C4E-A315-02247461D9D4/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/add_to_multifile_gist} (100%) rename Contents/Resources/{67262491-0033-4FF6-9AB7-46187500012D/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/annotate_blame_comment_line} (100%) rename Contents/Resources/{4D3B092F-0ABC-4152-923B-99D0B94B46B9/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/create_gist_from_selection} (100%) rename Contents/Resources/{4F4468C5-5CF8-4272-B87C-7CF1A56B1710/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/create_private_gist_from_selection} (100%) rename Contents/Resources/{C5646D06-0BE2-49EA-B672-B34F56F880EB/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/send_multifile_gist} (100%) rename Contents/Resources/{C8E0241B-0139-4DA0-A077-E1396148A1F9/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/send_private_multifile_gist} (100%) rename Contents/Resources/{DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/script => 452D34DC-9122-4196-9BB1-BA571D21A8BB/show_in_github} (100%) rename Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/{script => show_network_in_github} (100%) delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_line_in_commit_in_github.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/add_to_multifile_gist.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/comment_on_line.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/create_gist_from_selection.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/send_multifile_gist.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_in_github.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_network_in_github.rb delete mode 100755 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/gist.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git-ext/commit.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git_manager.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/show_in_github.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/tmp_gists delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_manager.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_object_commit.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_helper.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_in_github.rb delete mode 100644 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_line_in_commit_in_github.rb diff --git a/Contents/Info.plist b/Contents/Info.plist index 1af6864..fdff067 100644 --- a/Contents/Info.plist +++ b/Contents/Info.plist @@ -38,9 +38,9 @@ output showAsTooltip script - script + annotate_blame_comment_line uuid - 67262491-0033-4FF6-9AB7-46187500012D + 452D34DC-9122-4196-9BB1-BA571D21A8BB input @@ -54,9 +54,9 @@ output showAsTooltip script - script + add_to_multifile_gist uuid - 51A5A6E5-7A54-4C4E-A315-02247461D9D4 + 452D34DC-9122-4196-9BB1-BA571D21A8BB input @@ -70,9 +70,9 @@ output showAsTooltip script - script + create_private_gist_from_selection uuid - 4F4468C5-5CF8-4272-B87C-7CF1A56B1710 + 452D34DC-9122-4196-9BB1-BA571D21A8BB input @@ -86,9 +86,9 @@ output showAsTooltip script - script + create_gist_from_selection uuid - 4D3B092F-0ABC-4152-923B-99D0B94B46B9 + 452D34DC-9122-4196-9BB1-BA571D21A8BB input @@ -102,9 +102,9 @@ output showAsTooltip script - script + send_private_multifile_gist uuid - C8E0241B-0139-4DA0-A077-E1396148A1F9 + 452D34DC-9122-4196-9BB1-BA571D21A8BB fallbackInput @@ -120,9 +120,9 @@ output showAsTooltip script - script + show_in_github uuid - DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9 + 452D34DC-9122-4196-9BB1-BA571D21A8BB input @@ -136,9 +136,9 @@ output showAsTooltip script - script + send_multifile_gist uuid - C5646D06-0BE2-49EA-B672-B34F56F880EB + 452D34DC-9122-4196-9BB1-BA571D21A8BB fallbackInput @@ -154,7 +154,7 @@ output showAsTooltip script - script + show_network_in_github uuid 452D34DC-9122-4196-9BB1-BA571D21A8BB diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/add_to_multifile_gist similarity index 100% rename from Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/add_to_multifile_gist diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/annotate_blame_comment_line similarity index 100% rename from Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/annotate_blame_comment_line diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/create_gist_from_selection similarity index 100% rename from Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/create_gist_from_selection diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/create_private_gist_from_selection similarity index 100% rename from Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/create_private_gist_from_selection diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/send_multifile_gist similarity index 100% rename from Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/send_multifile_gist diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/send_private_multifile_gist similarity index 100% rename from Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/send_private_multifile_gist diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/show_in_github similarity index 100% rename from Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/show_in_github diff --git a/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/script b/Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/show_network_in_github similarity index 100% rename from Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/script rename to Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/show_network_in_github diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/tmp_gists b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/tmp_gists b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/tmp_gists b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/comment_on_line.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_in_github.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_network_in_github.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/gist.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git-ext/commit.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git_manager.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/show_in_github.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/tmp_gists b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_manager.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_object_commit.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_helper.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_in_github.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/comment_on_line.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_in_github.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_network_in_github.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/gist.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git-ext/commit.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git_manager.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/show_in_github.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/tmp_gists b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_manager.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_object_commit.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_helper.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_in_github.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/comment_on_line.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_in_github.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_network_in_github.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/gist.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git-ext/commit.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git_manager.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/show_in_github.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/tmp_gists b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_manager.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_object_commit.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_helper.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_in_github.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/add_to_multifile_gist.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/add_to_multifile_gist.rb deleted file mode 100644 index 5ad21ec..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/add_to_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.process_selection diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/comment_on_line.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/comment_on_line.rb deleted file mode 100644 index fda9e90..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/comment_on_line.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -if ENV['TM_INPUT_START_LINE'] - puts "Do not select lines, just leave the cursor on a line of interest" - exit -end - -begin - if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE']) - `open #{url}` - else - puts "This line has been modified or commit has not been pushed to GitHub" - end -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/create_gist_from_selection.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/create_gist_from_selection.rb deleted file mode 100644 index 94d52cb..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/create_gist_from_selection.rb +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.clear -Gist.process_selection -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/send_multifile_gist.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/send_multifile_gist.rb deleted file mode 100644 index 0f95afb..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/send_multifile_gist.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "gist" - -Gist.send(ARGV[0] == "private") diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_in_github.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_in_github.rb deleted file mode 100644 index d686c74..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_in_github.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "show_in_github" - -begin - url = ShowInGitHub.url_for(ENV['TM_FILEPATH']) - lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER'] - `open #{url}#L#{lines}` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_network_in_github.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_network_in_github.rb deleted file mode 100644 index 22dd6ba..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_network_in_github.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + "/../lib") -require "rubygems" -require "git_manager" - -begin - git = GitManager.new(ENV['TM_FILEPATH']) - url = git.github_url_for_project - - `open #{url}network` -rescue NotGitRepositoryError - puts "File/project not a git repository" -rescue NotGitHubRepositoryError - puts "File/project has not been pushed to a github repository" -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/gist.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/gist.rb deleted file mode 100755 index 089f906..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/gist.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2008 Chris Wanstrath -# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master - -require 'open-uri' -require 'net/http' - -module Gist - extend self - - @@gist_url = 'http://gist.github.com/%s.txt' - @@files = [] - - def read(gist_id) - open(@@gist_url % gist_id).read - end - - def add_file(name, content) - load_files - @@files << {:name => name, :content => content} - puts "#{name} added." - save_files - end - - def write(private_gist) - load_files - url = URI.parse('http://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) - url = copy req['Location'] - puts "Created gist at #{url}. URL copied to clipboard." - clear - end - - def clear - @@files = [] - save_files - end - - def process_selection - selection = nil - gistname = nil - if ENV['TM_SELECTED_TEXT'] - selection = ENV['TM_SELECTED_TEXT'] - gistname = "snippet" << "." << get_extension - else - selection = STDIN.read - gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension - end - - add_file(gistname, selection) - end - - # Add extension for supported modes based on TM_SCOPE - # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el - def get_extension - scope = ENV["TM_SCOPE"].split[0] - case scope - when /source\.actionscript/ then "as" - when /source\.c/, /source\.objc/ then "c" - when /source\.c\+\+/, /source\.objc\+\+/ then "cpp" - # common-lisp-mode then "el" - when /source\.css/ then "css" - when /source\.diff/, "meta.diff.range" then "diff" - # emacs-lisp-mode then "el" - when /source\.erlang/ then "erl" - when /source\.haskell/, "text.tex.latex.haskel" then "hs" - when /text\.html/ then "html" - when /source\.io/ then "io" - when /source\.java/ then "java" - when /source\.js/ then "js" - # jde-mode then "java" - # js2-mode then "js" - when /source\.lua/ then "lua" - when /source\.ocaml/ then "ml" - when /source\.objc/, "source.objc++" then "m" - when /source\.perl/ then "pl" - when /source\.php/ then "php" - when /source\.python/ then "sc" - when /source\.ruby/ then "rb" # Emacs bundle uses rbx - when /text\.plain/ then "txt" - when /source\.sql/ then "sql" - when /source\.scheme/ then "scm" - when /source\.smalltalk/ then "st" - when /source\.shell/ then "sh" - when /source\.tcl/, "text.html.tcl" then "tcl" - when /source\.lex/ then "tex" - when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml" - else "txt" - end - end - -private - def load_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - save_files unless File.exists?(path) - @@files = Marshal.load(File.read(path)) - @@files ||= [] - end - - def save_files - path = File.join(File.dirname(__FILE__), 'tmp_gists') - File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) } - end - - def copy(content) - return content if `which pbcopy`.strip == '' - IO.popen('pbcopy', 'r+') { |clip| clip.puts content } - content - end - - def data(private_gist) - params = {} - @@files.each_with_index do |file, i| - params.merge!({ - "file_ext[gistfile#{i+1}]" => nil, - "file_name[gistfile#{i+1}]" => file[:name], - "file_contents[gistfile#{i+1}]" => file[:content] - }) - end - params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth) - end - - def auth - user = `git config --global github.user`.strip - token = `git config --global github.token`.strip - - user.empty? ? {} : { :login => user, :token => token } - end -end - diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git-ext/commit.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git-ext/commit.rb deleted file mode 100644 index 9112901..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git-ext/commit.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Git::Object::Commit - # Ordered list of files within a commit - def file_paths - diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq - end -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git_manager.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git_manager.rb deleted file mode 100644 index a52df0d..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git_manager.rb +++ /dev/null @@ -1,131 +0,0 @@ -gem 'git', '>=1.0.0' -require 'git' -require 'git-ext/commit' -require 'net/http' - -class GitManager - attr_reader :git, :target_file - - def initialize(target_file) - @target_file = target_file || "" - find_working_dir - end - - def remotes - config_remotes = config.keys.inject([]) do |mem, key| - if key =~ %r{\Aremote\.(.*)\.url} - mem << $1 - end - mem - end - end - - def github_remotes - remotes.inject([]) do |mem, remote| - if repo_for_remote(remote) =~ %r{github\.com} - mem << remote - end - mem - end - end - - def best_github_remote - remotes = github_remotes - selected_remote = 'github' if remotes.include?('github') - selected_remote ||= 'origin' if remotes.include?('origin') - selected_remote ||= remotes.first - raise NotGitHubRepositoryError unless selected_remote - - return selected_remote - end - - def user_project_from_repo(repo) - if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git} - return {:user => $1, :project => $2} - end - return - end - - def github_url_for_project(github_remote=nil) - github_remote ||= best_github_remote - repo = repo_for_remote(github_remote) - if user_project = user_project_from_repo(repo) - url_head(user_project) - end - end - - def file_to_github_url(github_remote, branch='master', file=nil) - file ||= target_file - branch ||= @git.current_branch - repo = repo_for_remote(github_remote) - path = file.gsub(working_path, '').gsub(%r{\A/},'') - if user_project = user_project_from_repo(repo) - user, project = $1, $2 - response = nil - url_head(user_project, branch) + "/#{path}" - end - end - - def relative_file(file=nil) - file ||= target_file - file = File.expand_path(file).sub(%r{\A#{working_path}/}, '') - end - - # Returns the Git::Object::Commit that adds a +line+ - def find_commit_with_line(line) - git.log.path(@file).each do |commit| - return commit if line_in_diff?(commit.diff_parent.to_s, line) - end - nil - end - - # Check if the exact line was added in a specific commit (via its parent_diff) - # TODO - Ensure line is within specific +file+, else might get match within wrong file - # parent_diff - the results of Git::Object::Commit#parent_diff - # line - the exact string to match on one line of the diff - def line_in_diff?(parent_diff, line) - parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" } - end - - def git? - git - end - - def working_path - git.instance_variable_get("@working_directory").path - end - - protected - def config - git.config - end - - def find_working_dir - path = File.dirname(File.expand_path(target_file)) - path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"] - @git = nil - while !@git && path_bits.length > 1 - path = path_bits.join('/') - path_bits.pop unless (@git = Git.open(path) rescue nil) - end - raise NotGitRepositoryError unless @git - end - - def repo_for_remote(remote) - config["remote.#{remote}.url"] - end - - def url_head(user_project, branch='') - branch = "tree/#{branch}" if branch != '' - project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}" - project_private?(project_path) ? - "https://github.com#{project_path}" : "http://github.com#{project_path}" - end - - def project_private?(project_path) - response=nil - Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) } - response and response.code.to_i == 302 and response['location'] =~ %r{https:} - end - -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/show_in_github.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/show_in_github.rb deleted file mode 100644 index 782e4fa..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/show_in_github.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'git_manager' - -class NotGitRepositoryError < Exception; end -class NotGitHubRepositoryError < Exception; end -class CommitNotFoundError < Exception; end -# SocketError can be thrown when testing public access to repo - -module ShowInGitHub - extend self - attr_reader :git - - def url_for(file_path) - @git = GitManager.new(file_path) - git.file_to_github_url(git.best_github_remote) - end - - # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead - # -l complete hash - # -s strips user fu - def line_to_github_url(file_path, line_str) - return nil unless file_url = url_for(file_path) - project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '') - commit = git.find_commit_with_line(line_str) - return nil unless commit - file_index = commit.file_paths.index(git.relative_file(file_path)) - "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}" - end - - -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/tmp_gists b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/tmp_gists deleted file mode 100644 index 4e1be222d39b0b261d3068077916294527533fe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSKh-Tmd00C40asU7T diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_manager.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_manager.rb deleted file mode 100644 index b892c67..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_manager.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" - -class TestGitManager < Test::Unit::TestCase - def setup - @git = GitManager.new(__FILE__) # pass this file just cause we need some file - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - end - - def test_get_remotes - expected = %w[origin rubyforge] - assert_equal(expected, @git.remotes) - end - - def test_get_remotes_on_github - expected = %w[origin] - assert_equal(expected, @git.github_remotes) - end - - def test_github_pages_account_remote_urls_can_be_parsed - @git.stubs(:config).returns({ - "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com", - "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*" - }) - expected = "http://github.com/railscampau/railscampau.github.com/" - assert_equal(expected, @git.github_url_for_project) - end -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_object_commit.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_object_commit.rb deleted file mode 100644 index 679e204..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_object_commit.rb +++ /dev/null @@ -1,22 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestGitObjectCommit < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_extract_file_paths_from_commit - mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221" - expected_files = [ - 'Support/lib/git_manager.rb', - 'Support/test/test_helper.rb', - 'Support/test/test_show_line_in_commit_in_github.rb' - ] - commit = Git::Object::Commit.new(git.git, mutli_file_commit) - actual_files = commit.file_paths - assert_equal(expected_files, actual_files) - end -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_helper.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_helper.rb deleted file mode 100644 index 39bf7ee..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test/unit" -$:.unshift(File.dirname(__FILE__) + "/../lib") - -require "pp" -require 'rubygems' -%w[mocha Shoulda].each do |gem_name| - begin - require gem_name - rescue LoadError => e - puts "You must install #{gem_name} rubygem before running these tests" - exit - end -end - -require "git_manager" \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_in_github.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_in_github.rb deleted file mode 100644 index 7064fcf..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_in_github.rb +++ /dev/null @@ -1,84 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowInGithub < Test::Unit::TestCase - def setup - GitManager.any_instance.stubs(:git?).returns(true) - GitManager.any_instance.stubs(:project_private?).returns(false) - end - - def test_do_nothing_if_file_not_under_git_repo - GitManager.any_instance.stubs(:git?).returns(false) - GitManager.any_instance.stubs(:config).returns(nil) - assert_raise(NotGitRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_do_nothing_if_no_repo_is_with_github - GitManager.any_instance.stubs(:config).returns({ - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - assert_raise(NotGitHubRepositoryError) do - ShowInGitHub.url_for("/some/path/to/file") - end - end - - def test_construct_github_url_for_file - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git", - "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*", - "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*", - "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_github_over_other_remote_names - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.github.url"=>"git@github.com:drnic/newgem-github.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-github/tree/master/to/file" - assert_equal(expected, url) - end - - def test_prioritize_origin_over_other_remote_names_except_origin - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git", - "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git", - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem-origin/tree/master/to/file" - assert_equal(expected, url) - end - - def test_project_is_private_should_use_https - GitManager.any_instance.stubs(:project_private?).returns(true) - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git@github.com:drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "https://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end - - def test_anonymous_repo - GitManager.any_instance.stubs(:config).returns({ - "remote.origin.url"=>"git://github.com/drnic/newgem.git" - }) - GitManager.any_instance.stubs(:working_path).returns("/some/path") - url = ShowInGitHub.url_for("/some/path/to/file") - expected = "http://github.com/drnic/newgem/tree/master/to/file" - assert_equal(expected, url) - end -end \ No newline at end of file diff --git a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_line_in_commit_in_github.rb b/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_line_in_commit_in_github.rb deleted file mode 100644 index a8cb531..0000000 --- a/Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_line_in_commit_in_github.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + "/test_helper" -require "show_in_github" - -class TestShowLineInCommitInGitHub < Test::Unit::TestCase - attr_reader :git - def setup - @git = GitManager.new __FILE__ - @file = git.relative_file - puts "These tests require the project to be checked out of git to work" unless @git - end - - def test_find_first_commit_for_this_file - line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03" - actual = git.find_commit_with_line(line_in_first_commit) - assert_equal(expected, actual.to_s) - end - - def test_find_line_in_diff - # diff_parent is a reverse diff, so added lines prefix with -; removed lines + - diff_parent = <<-DIFF -diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb -deleted file mode 100644 -index 63b416f..0000000 ---- a/Support/test/test_show_line_in_commit_in_github.rb -+++ /dev/null -@@ -1,8 +0,0 @@ --require File.dirname(__FILE__) + "/test_helper" --require "show_in_github" -- --class TestShowLineInCommitInGitHub < Test::Unit::TestCase -- def test_find_first_commit_for_this_file -- -- end --end -\ No newline at end of file - DIFF - current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase" - assert git.line_in_diff?(diff_parent, current_line), "should find line in diff" - assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff" - end - - def test_github_url_for_line_in_commit - url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit") - expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2" - assert_equal(expected, url) - end - - should_eventually "test_file_index_within_multi_file_commit" do - end -end \ No newline at end of file