Skip to content

Commit

Permalink
Merge branch 'pull/390'
Browse files Browse the repository at this point in the history
Closes: wincent/command-t#390

* pull/390:
  docs: update AUTHORS and HISTORY section
  refactor: make .watchmanconfig a valid JSON file
  style: apply comment edits and remove an unnecessary semi-colon
  perf: use watchman's `watch-project` if available
  • Loading branch information
Padmamanickam authored and wincent committed Jun 18, 2022
2 parents 765410e + cb7bffe commit 92622bf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 35 deletions.
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
58 changes: 32 additions & 26 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1413,32 +1413,32 @@ AUTHORS *command-t-authors*
Command-T is written and maintained by Greg Hurrell <greg@hurrell.net>.
Other contributors that have submitted patches include, in alphabetical order:

Abhinav Gupta Nate Kane
Adrian Keet Nicholas T.
Aleksandrs Ļedovskis Nicolas Alpi
Alexey Terekhov Nikolai Aleksandrovich Pavlov
Andrius Grabauskas Nilo César Teixeira
Andy Waite Noon Silk
Anthony Panozzo Ole Petter Bang
Artem Nezvigin Patrick Hayes
Ben Boeckel Paul Jolly
Brendan Mulholland Pavel Sergeev
Daniel Burgess Rainux Luo
Daniel Hahler Richard Feldman
David Emett Roland Puntaier
David Szotten Ross Lagerwall
Douglas Drumond Sam Morris
Emily Strickland Scott Bronson
Felix Tjandrawibawa Seth Fowler
Gary Bernhardt Sherzod Gapirov
Henric Trotzig Shlomi Fish
Ivan Ukhov Stefan Schmidt
Jakob Pfender Stephen Gelman
Jeff Kreeftmeijer Steve Herrell
Jerome Castaneda Steven Moazami
Joe Lencioni Steven Stallion
KJ Tsanaktsidis Sung Pae
Kevin Webster Thomas Pelletier
Abhinav Gupta Nicholas T.
Adrian Keet Nicolas Alpi
Aleksandrs Ļedovskis Nikolai Aleksandrovich Pavlov
Alexey Terekhov Nilo César Teixeira
Andrius Grabauskas Noon Silk
Andy Waite Ole Petter Bang
Anthony Panozzo Patrick Hayes
Artem Nezvigin Paul Jolly
Ben Boeckel Pavel Sergeev
Brendan Mulholland Rainux Luo
Daniel Burgess Richard Feldman
Daniel Hahler Roland Puntaier
David Emett Ross Lagerwall
David Szotten Sam Morris
Douglas Drumond Scott Bronson
Emily Strickland Seth Fowler
Felix Tjandrawibawa Sherzod Gapirov
Gary Bernhardt Shlomi Fish
Henric Trotzig Stefan Schmidt
Ivan Ukhov Stephen Gelman
Jakob Pfender Steve Herrell
Jeff Kreeftmeijer Steven Moazami
Jerome Castaneda Steven Stallion
Joe Lencioni Sung Pae
KJ Tsanaktsidis Thomas Pelletier
Kevin Webster Todd Derr
Kien Nguyen Duc Ton van den Heuvel
Lucas de Vries Victor Hugo Borja
Marcus Brito Vlad Seghete
Expand All @@ -1447,6 +1447,7 @@ Other contributors that have submitted patches include, in alphabetical order:
Max Timkovich Yan Pritzker
Mike Lundy Zak Johnson
Nadav Samet xiaodezhang
Nate Kane

This list produced with:

Expand Down Expand Up @@ -1572,6 +1573,11 @@ POSSIBILITY OF SUCH DAMAGE.

HISTORY *command-t-history*

main (not yet released) ~

- Teach watchman scanner to favor `watch-project` over `watch` when
available (#390, patch from Todd Derr).

5.0.4 (28 May 2022) ~

- Support opening files which contain newlines (#365).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ def paths!

UNIXSocket.open(sockname) do |socket|
root = Pathname.new(@path).realpath.to_s
roots = Watchman::Utils.query(['watch-list'], socket)['roots']
if !roots.include?(root)
# this path isn't being watched yet; try to set up watch
result = Watchman::Utils.query(['watch', root], socket)
# Use `watch-project` for efficiency if available.
if use_watch_project?
result = Watchman::Utils.query(['watch-project', root], socket)
root = extract_value(result, 'watch')
relative_root = extract_value(result, 'relative_path') if result.has_key?('relative_path')
else
roots = Watchman::Utils.query(['watch-list'], socket)['roots']
if !roots.include?(root)
# This path isn't being watched yet; try to set up watch.
result = Watchman::Utils.query(['watch', root], socket)

# root_restrict_files setting may prevent Watchman from working
# or enforce_root_files/root_files (>= version 3.1)
extract_value(result)
# `root_restrict_files` setting may prevent Watchman from
# working or enforce_root_files/root_files (>= version 3.1).
extract_value(result)
end
end

query = ['query', root, {
query_params = {
'expression' => ['type', 'f'],
'fields' => ['name'],
}]
}
query_params['relative_root'] = relative_root if relative_root
query = ['query', root, query_params]
paths = Watchman::Utils.query(query, socket)

# could return error if watch is removed
Expand Down Expand Up @@ -68,6 +77,15 @@ def get_raw_sockname
end
raw_sockname
end

# `watch_project` is available in 3.1+ but it's awkward to use without
# `relative_root` (3.3+), so use the latter as our minimum version.
def use_watch_project?
return @use_watch_project if defined?(@use_watch_project)
version = %x{watchman --version 2>/dev/null}
major, minor = version.split('.')[0..1] if !$?.exitstatus.nil? && $?.exitstatus.zero? && version
@use_watch_project = major.to_i > 3 || (major.to_i == 3 && minor.to_i >= 3)
end
end
end
end
Expand Down

0 comments on commit 92622bf

Please sign in to comment.