dpu 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +45 -14
- data/lib/dpu/version.rb +1 -1
- data/lib/dpu.rb +4 -4
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da25d251c912637fae3d9b0a1604e97b9f3479af31e621d81ccb90f6048bbcc0
|
4
|
+
data.tar.gz: b63ff8c41e71070fa4f4367b69789fa04cec03bd9b437a43486a5a744b05448a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf4237d310747c045fe46f696349d21a85cf72b9c6043c5adde93347e7289022b05593580677e656d209ce393f482b73b28a90b487422a9411b4c918147e1c4
|
7
|
+
data.tar.gz: '097de31dadb39d9fe725507de6fcea2706a8f75c04c330a706686740857bb3df92d29c1a5be63826b509c0cf63496a527d22842408daa628cd93880767f5d00e'
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya.Nishida.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: version_sorter
|
@@ -88,7 +88,8 @@ files:
|
|
88
88
|
- lib/dpu/version.rb
|
89
89
|
- sig/dpu.rbs
|
90
90
|
homepage: https://github.com/nishidayuya/dpu
|
91
|
-
licenses:
|
91
|
+
licenses:
|
92
|
+
- X11
|
92
93
|
metadata:
|
93
94
|
homepage_uri: https://github.com/nishidayuya/dpu
|
94
95
|
source_code_uri: https://github.com/nishidayuya/dpu
|
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
- !ruby/object:Gem::Version
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.5.16
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: determine permanent URI
|