dpu 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -14
- data/lib/dpu/version.rb +1 -1
- data/lib/dpu.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590a2cd53e8775d56f0b470b0407789f1d7bf7ee47c2b3c2f0f8fcb19d1805e7
|
4
|
+
data.tar.gz: dfa3ef6408df75dcfd83712a65c6a2020b5949c164d93c99ec85328530ffe1a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08e259ce385484109aa453fa7c30e61765aae3721e947c729535f8a53814c17ebcd62ca8f31809ecd6c7396594d59dbd91f98c9682e28bc3f0736d51cd61986a'
|
7
|
+
data.tar.gz: 56234fd78513c30ccfbe571dacafffc010a7572f40c25ff87a6656e69c1e8941ea756ab45470ad2a06196f666d4582c1cca219d0d5b217153444efc9fde0c709
|
data/README.md
CHANGED
@@ -39,28 +39,55 @@ $ dpu path_to_code start_line_number end_line_number
|
|
39
39
|
|
40
40
|
Write following code to your `.emacs`, and evaluate it.
|
41
41
|
|
42
|
+
<details>
|
43
|
+
|
44
|
+
<summary>.emacs sample</summary>
|
45
|
+
|
42
46
|
```emacs-lisp
|
43
47
|
(define-key global-map (kbd "C-x L")
|
44
48
|
(lambda ()
|
45
49
|
(interactive)
|
46
|
-
(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
(save-window-excursion
|
51
|
+
(let* ((start-line-number (line-number-at-pos (if (region-active-p) (region-beginning))))
|
52
|
+
(end-line-number
|
53
|
+
(if mark-active
|
54
|
+
(line-number-at-pos
|
55
|
+
(+ (region-end)
|
56
|
+
(if (= (line-beginning-position) (region-end)) -1 0)))
|
57
|
+
))
|
58
|
+
(proc (apply
|
59
|
+
#'start-process
|
60
|
+
"dpu" "*Dpu Command Result*"
|
61
|
+
"dpu" buffer-file-name
|
62
|
+
(number-to-string start-line-number)
|
63
|
+
(if end-line-number
|
64
|
+
(list (number-to-string end-line-number)))
|
65
|
+
))
|
66
|
+
(kill-new-with-buffer-string
|
67
|
+
(lambda (process signal)
|
68
|
+
(when (memq (process-status process) '(exit signal))
|
69
|
+
(let* ((buf (process-buffer process)))
|
70
|
+
(with-current-buffer buf
|
71
|
+
(kill-new (s-chomp (buffer-string)))
|
72
|
+
(message "Copied: %s" (current-kill 0 t))
|
73
|
+
(kill-buffer buf)
|
74
|
+
)))))
|
75
|
+
)
|
76
|
+
(run-with-timer 10 nil (lambda (process) (kill-buffer (process-buffer process))) proc)
|
77
|
+
(if (process-live-p proc)
|
78
|
+
(set-process-sentinel proc kill-new-with-buffer-string))
|
79
|
+
)
|
80
|
+
)))
|
60
81
|
```
|
61
82
|
|
83
|
+
</details>
|
84
|
+
|
62
85
|
Then type `C-x L` to copy permanent URI. `C-y` to paste it.
|
63
86
|
|
87
|
+
---
|
88
|
+
|
89
|
+
Original asynchronous execution idea is made by [@mk2](https://github.com/mk2) ([#20](https://github.com/nishidayuya/dpu/pull/20)). Thanks! :tada:
|
90
|
+
|
64
91
|
### Textbringer integration
|
65
92
|
|
66
93
|
```ruby
|
@@ -76,6 +103,10 @@ end
|
|
76
103
|
GLOBAL_MAP.define_key("\C-xL", :copy_permanent_uri)
|
77
104
|
```
|
78
105
|
|
106
|
+
### Visual Studio Code integration
|
107
|
+
|
108
|
+
See [Copy permanent URL](https://marketplace.visualstudio.com/items?itemName=nishidayuya.copy-permanent-url) extension on Visual Studio Marketplace.
|
109
|
+
|
79
110
|
### Other editor integration
|
80
111
|
|
81
112
|
Write pull-request or issue, please!
|
data/lib/dpu/version.rb
CHANGED
data/lib/dpu.rb
CHANGED
@@ -11,7 +11,7 @@ module Dpu
|
|
11
11
|
SCM_SERVICES = []
|
12
12
|
|
13
13
|
class << self
|
14
|
-
def determine_permanent_uri(path_or_link, start_line_number: nil, end_line_number: nil)
|
14
|
+
def determine_permanent_uri(path_or_link, start_line_number: nil, end_line_number: nil, max_find_version: 20)
|
15
15
|
path = path_or_link.realpath
|
16
16
|
relative_path = determine_relative_path(path)
|
17
17
|
|
@@ -21,7 +21,7 @@ module Dpu
|
|
21
21
|
permanent_uri_parts = [
|
22
22
|
repository_uri,
|
23
23
|
scm_service.ref_prefix,
|
24
|
-
find_same_content_version(path, relative_path) || determine_commit_id(path),
|
24
|
+
find_same_content_version(path, relative_path, max_find_version) || determine_commit_id(path),
|
25
25
|
relative_path,
|
26
26
|
]
|
27
27
|
permanent_uri = URI(permanent_uri_parts.join("/"))
|
@@ -65,12 +65,12 @@ module Dpu
|
|
65
65
|
return commit_id
|
66
66
|
end
|
67
67
|
|
68
|
-
def find_same_content_version(path, relative_path_from_repository_root)
|
68
|
+
def find_same_content_version(path, relative_path_from_repository_root, max_find_version)
|
69
69
|
stdout = run_command(*%w[git tag --list [0-9]* v[0-9]*], chdir: path.dirname)
|
70
70
|
versions = VersionSorter.sort(stdout.each_line(chomp: true).select(&:ascii_only?))
|
71
71
|
|
72
72
|
content_in_head = path.read
|
73
|
-
same_content_version = versions.reverse_each.find { |version|
|
73
|
+
same_content_version = versions.reverse_each.take(max_find_version).find { |version|
|
74
74
|
content_in_version, _stderr, _status = *Open3.capture3(
|
75
75
|
*%W[git show #{version}:#{relative_path_from_repository_root}],
|
76
76
|
chdir: path.dirname,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya.Nishida.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: version_sorter
|