Compare commits

...

516 commits

Author SHA1 Message Date
Rich Chiodo
698499e9ec
Add support for space in the python file (#1982)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
* Add support for space in the python file itself when using shell expansion.

* Fix linter

* Fix flakey test
2025-12-12 16:04:10 -08:00
Rich Chiodo
e5017d7360
Fix arq quoting to work in runInTerminal (#1981)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
* Fix arq quoting to work in runInTerminal

* Default was backwards

* Fix ruff errors

* Fix failing tests

* Only strip quotes on the exe

* Try fixing gw worker failures

* Skip certain test because of cmd limitations

* Need to skip all 'code' based tests on windows
2025-12-10 10:39:27 -08:00
Pavel Karateev
1e3fd91306
fix the link to Python extension in CONTRIBUTING.md (#1934)
Some checks are pending
Code scanning - action / CodeQL-Build (push) Waiting to run
2025-12-09 09:30:02 -08:00
Rich Chiodo
378339a3a8
Update team rotation list in round-robin workflow (#1978)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
2025-12-01 10:49:43 -08:00
Bill Schnurr
93d93f2d6c
Update CODEOWNERS to remove a reviewer (#1979)
Removed @microsoft/debugpy-CodeReviewers from default owners.
2025-12-01 10:25:46 -08:00
Bill Schnurr
8f13145a23
Add pyrx-admins as code owners (#1976)
* Add pyrx-admins as code owners

* Combine CODEOWNERS entries into a single line
2025-12-01 10:17:06 -08:00
Karthik Nadig
275caca690
Add gcc flags (#1947) 2025-12-01 09:58:08 -08:00
lev-blit
82e409e883
include py.typed in the distributed package (#1960)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
2025-10-01 09:09:28 -07:00
Bill Schnurr
6cbdf8767e
update testing for python 3.14 (#1955)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
* update testing for python 3.14

* Allow python 3.14 in attach code

* move 3.14 to its own job outside of matrix

* try 3.14.0-rc.2

* allowUnstable

* use 3.14.0-rc.2 but use 3.14 in tests
2025-09-05 09:14:53 -07:00
timrid
2eb3afede0
Check if os.__file__ is available before using it (#1944)
* check if os.file is available before using it

* use threading.__file__ als last fallback
2025-08-12 13:25:06 -07:00
Piotr Osiewicz
b00a812997
pydevd: Fix up prefix of attach shared library for Windows (#1939)
Follow-up to #1917, which changed the prefix for Windows. The crux of that contribution was about enabling attaching on Sillicon Mac (in fact, it came from my colleagues at Zed Industries). This however broke .dll lookup per https://github.com/zed-industries/zed/pull/35640#issuecomment-3155624377
2025-08-05 11:08:32 -07:00
Jordan Borean
1aff9aa541
Expose CLI Options through public API (#1928)
* Expose CLI Options through public API

Expose a public API that can retrieve the processed CLI options for the
current process launched through the debugpy CLI. This enables code to
be able to retrieve options like the port and adapter access token to be
used for launching their own child process' that can be debugged.

* Fix test by sending dict not dataclass object
2025-07-15 15:56:03 -07:00
Anuraag (Rag) Agrawal
ead90f6f71
Fix round-robin CI script when state issue has no assignees (#1930) 2025-07-15 09:47:51 -07:00
Jordan Borean
2b1e361eac
Document --adapter-access-token CLI arg (#1927) 2025-07-15 09:46:03 -07:00
Jordan Borean
ea1dd9a838
Fix debugger stepping actions in forked process (#1921)
* Fix debugger stepping actions in forked process

Fix the debugger stepping state when debugging a process that has been
forked from the main process. The new sys.monitoring mechanism didn't
fully clear the thread local storage after a fork leading to a state
where the forked child process tracked the wrong thread information and
was never updated on the latest continue action.

* Add stepping test for forked process

* Add line ending back in for cleaner diff

* More formatting reversions
2025-07-08 10:47:47 -07:00
Jordan Borean
b387710b7f
Add parent-session-pid argument (#1920)
* Add parent-session-pid argument

Add the ability to specify the parent process id when connecting a new
DAP server to the client. This value is used instead of the actual
process' parent id so that it can be associated with a specific debug
session even if it hasn't been spawned directly by that parent process.

* Add tests for new option
2025-07-07 09:52:53 -07:00
Conrad Irwin
0d65353cc6
Fix attach to process on arm64 Mac. (#1917)
* Before this change it was not possible to attach to a process on arm64 mac.

The primary issue was that we weren't building the attach.dylib for all targets; but even once we did that we had to ensure that we were exiting successfully after injecting into the process.

We pulled in the compile changes from 2e7109f6fe

Co-authored-by: @artemmukhin <Artem.Mukhin@jetbrains.com>
Co-authored-by: Cole Miller <cole@zed.dev>

* Use g++ on macOS (with -D_FORTIFY_SOURCE=2)

---------

Co-authored-by: @artemmukhin <Artem.Mukhin@jetbrains.com>
Co-authored-by: Cole Miller <cole@zed.dev>
2025-06-26 11:02:37 -07:00
MichaelSpece
99b202ee21
microsoft/debugpy#1898 Fix. (#1899) 2025-05-27 09:34:57 -07:00
rabbit
34d5de99a0
IPv6 support (#1896)
* Add initial support for IPv6

* address comments (part 1)

* quick clean up of missed fix suggestion

* Fix misassigned default serving server address in adapter client

* add wrapper method to get host and port from`getsockname`
2025-05-22 13:04:11 -07:00
Rich Chiodo
4bc7343c05
Fix 3.14 beta break with _handle on thread (#1895) 2025-05-19 11:12:37 -07:00
Rich Chiodo
8b5b84aec3
Update flags (#1889) 2025-04-10 11:38:49 -07:00
lachalek
644349da3e
feat: add monkey_patch_os for posix_spawnp (#1885)
* add monkey patch for posix_spawnp

* remove check for IS_PY38_OR_GREATER

---------

Co-authored-by: lydiachalek <lydiaboyd30@gmail.com>
2025-04-02 12:02:11 -07:00
Jonas Jelten
2d220f8db8
add debugpy-adapter entrypoint (#1870) 2025-03-13 08:59:39 -07:00
Rich Chiodo
f7d8963f99
Account for the scope when changing variables (#1869)
* Support using scope during setVariable request

* Fix other overloads to accept scope too

* Use 3.9 compatible unions

* Review feedback

* Pydevd test wasn't actually validating
2025-03-10 16:15:23 -07:00
Rich Chiodo
e01e6dd8a9
Get rid of silly raise/except clause (#1865) 2025-03-07 16:55:50 -08:00
Rich Chiodo
24001704d8
Try making the test_cli tests more robust on Python 3.13 (#1864) 2025-03-07 15:41:52 -08:00
Matej Aleksandrov
f054965148
Ensure Debugpy closes connection after a disconnect response (#1859)
* Ensure Debugpy closes connection after a disconnect response

* Moved disconnect fix from messaging to Client.disconnect_request
2025-03-07 11:14:32 -08:00
Rich Chiodo
96de4376a5
Fix binskim warnings for mac, linux, and pyd files (#1856)
* Add controlflow guard to linux, mac, and pyd files

* Fix manylinux too

* Fix pydevd bits too
2025-03-04 16:04:14 -08:00
Rich Chiodo
ed9f2949f6
Handle invalid __getattribute__ functions (#1833)
* Handle invalid `__getattribute__` functions

Addresses https://github.com/microsoft/debugpy/issues/1832

* Update src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py

Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>

---------

Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
2025-02-12 14:43:30 -08:00
bersbersbers
fb0b06cab1
Suppress warning on exit by properly closing pydevd socket (#1826)
* Fix #1812, first try

* Prevent tries to close socket multiple times
2025-02-05 09:53:37 -08:00
Karthik Nadig
4c226dd7e9
Add Terminate Debuggee capability (#1824) 2025-02-04 09:04:06 -08:00
Rich Chiodo
40a471e24a
Fix matplotlib backend computation (#1811)
* Fix matplotlib backend computation and problem found with just my code fix

* Remove extra logging
2025-01-15 09:42:03 -08:00
Rich Chiodo
d266361676
Allow relative paths in the 'remotePath' for a launch.json (#1803)
* Allow relative paths and add more logging for path issues

* Revert "Allow relative paths and add more logging for path issues"

This reverts commit a3956e4753.

* Allow relative paths and add more logging for path issues

* Add case test

* Missed some spots

* Invalid variable name

* Func doesn't return tuple
2025-01-09 14:32:39 -08:00
Rich Chiodo
02723de140
Fix multithreading stepping in 3.12 and later (#1798)
* Fix multithreaded stepping to not have 'return' events when a thread is already suspended

* Update after removing blank line

* Remove unnecessary change for start method
2025-01-07 11:25:54 -08:00
Rich Chiodo
7597262c80
Fix pyqt6 loader on windows (#1797) 2025-01-07 09:49:46 -08:00
Gary Miguel
cc85ca8e01
Handle new matplotlib versions (#1791)
Fixes: https://github.com/microsoft/debugpy/issues/1623
2025-01-06 09:47:23 -08:00
Rich Chiodo
24aa6a5f8e
Fix problem with just my code being ignored during stepping (#1786) 2024-12-19 08:32:04 -08:00
Adam Yoblick
34cc53b2ac
Merge pull request #1779 from microsoft/remove_bytecode_distinfo
Remove bytecode distinfo causing PyPi publish errors and ignore it from now on
2024-12-12 16:28:51 -06:00
Adam Yoblick
a99d933411 Remove bytecode distinfo causing PyPi publish errors and ignore it from now on 2024-12-12 15:44:37 -06:00
Luke Riddle
5014f2538a
Properly update pydevd._settrace.called (#1751)
* Properly update pydevd._settrace.called

* Change _settrace.called to _listen.called

* Remove unnecessary underscore from listen

* Fix lint issues

* Update multiple listen test
2024-12-06 14:48:58 -08:00
Rich Chiodo
43f41029ea
Make sure attach binaries are built before running tox (#1753)
* Make sure attach binaries are built before running tox

* Fix errors on 3.13
2024-12-03 15:27:42 -08:00
Luke Riddle
a78e5c28cd
Fix path modification for windows filesystems that can't handle .. (#1752) 2024-12-03 10:09:32 -08:00
Rich Chiodo
3823aba95e
Fix problem with lineno being none when generating traceback (#1750)
* Fix problem with lineno being none when generating traceback

Fixes https://github.com/microsoft/debugpy/issues/1745

* Improve multiline statement handling in stack summary
2024-12-02 11:57:30 -08:00
Rich Chiodo
f4ba976121
Subrepo command wasn't checked in correctly (#1737)
* Remove subrepo

* Fix subrepo
2024-11-18 09:50:34 -08:00
Rich Chiodo
73be8fb5df
Takes some changes from pydevd to fix line numbers being None (#1734)
* Add missing subrepo tools

* Update parent

* git subrepo commit (merge) src/debugpy/_vendored/pydevd

subrepo:
  subdir:   "src/debugpy/_vendored/pydevd"
  merged:   "c81fc701"
upstream:
  origin:   "https://github.com/fabioz/PyDev.Debugger.git"
  branch:   "main"
  commit:   "d0f81de4"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"

* Update sys_monitoring c file

* Try avoiding test errors on shutdown

* Try fixing case where closing early

* Run PRs everywhere
2024-11-14 16:22:19 -08:00
Rich Chiodo
3573ca0e2b
Remove compiled files (#1723) 2024-11-07 15:11:48 -08:00
Adam Yoblick
7d0ff33340
Merge pull request #1725 from microsoft/publish_pydevd_binaries 2024-11-07 15:02:49 -06:00
Adam Yoblick
af0d29f6bc Missed some quotes 2024-11-07 10:07:15 -06:00
Adam Yoblick
cebb7475a3 Remove redundant double quotes 2024-11-07 10:06:43 -06:00
Adam Yoblick
2036f44606 Change job names in build matrix 2024-11-07 10:02:43 -06:00
Adam Yoblick
22fbc53ee3 Move lint and pydevd to their own stages 2024-11-07 09:53:16 -06:00
Adam Yoblick
37eaf86e1a Copy downloaded binaries to the right place before running tests 2024-11-06 16:56:49 -06:00
Adam Yoblick
db63cd5bd1 build pydevd biniaries, publish them, and download them in later jobs 2024-11-06 16:47:11 -06:00
Adam Yoblick
abf4bb651a
Merge pull request #1722 from microsoft/build_pydevd_binaries
Build pydevd binaries before running tests
2024-11-05 14:25:29 -06:00
Adam Yoblick
1eb92e64b1 Fix bad paths 2024-11-05 13:33:38 -06:00
Adam Yoblick
8f2aed19da Build pydevd binaries before running tests 2024-11-05 13:18:52 -06:00
Rich Chiodo
740fa9dd5a
In 3.12 findlinestarts seems to return None for line more often (#1721) 2024-11-04 11:19:37 -08:00
Adam Yoblick
6a7f7c0f2d
Merge pull request #1718 from microsoft/remove_pydevd_workflow
Remove pydevd workflow since we build these as part of CI now
2024-11-01 17:20:42 -05:00
Adam Yoblick
b028e5c039 Remove pydevd workflow since we build these as part of CI now 2024-10-31 16:55:06 -05:00
Rich Chiodo
064a78f9cb
Update instructions for pushing changes to PyDev.Debugger (#1715)
* Update instructions

* Update attach to process.yml

* Update binaries
2024-10-30 15:51:36 -07:00
Rich Chiodo
a7d5a7ec12
Use subrepo to link to PyDev.Debugger instead of copying it (#1714)
* Remove copy of pydevd and add subrepo script

* git subrepo clone https://github.com/fabioz/PyDev.Debugger.git src/debugpy/_vendored/pydevd

subrepo:
  subdir:   "src/debugpy/_vendored/pydevd"
  merged:   "7d6e6e68"
upstream:
  origin:   "https://github.com/fabioz/PyDev.Debugger.git"
  branch:   "main"
  commit:   "7d6e6e68"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"

* Add binskim settings to match debugpy

* git subrepo clone --force https://github.com/fabioz/PyDev.Debugger.git src/debugpy/_vendored/pydevd

subrepo:
  subdir:   "src/debugpy/_vendored/pydevd"
  merged:   "cf2e47cb"
upstream:
  origin:   "https://github.com/fabioz/PyDev.Debugger.git"
  branch:   "main"
  commit:   "cf2e47cb"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"

* Remove unnecessary string test by removing the lambda in pydevd_sys_monitoring

* Fix linter

* Put back the fix in qt_loaders

* Put back binskim flag
2024-10-29 13:32:30 -07:00
Rich Chiodo
8ab4ee89e9
Try to get more logging from 3.13 failures (#1711)
* Add more logging for 313 failure

* Auto retry failures

* Add retry for socket.write

* Put watchdog timeout back and drop errors

* Fix linter

* Add message on error so at least it's logged

* Try a different combination

* Fix linter

* Go back to longer watchdog

* Try a different tactic

* Don't log failure and wait a bit in the watchdog

* Go back to the NoMoreMessages

* Just disable watchdog in 3.13 for now

* Change watchdog timeout

* Try different algorithm for ports in use

* Add retries option

* Fix usages of get_test_server_port

* Retries don't seem to work at global level with xdist, use retries on individual tests
2024-10-24 11:08:42 -07:00
Sarkis Ter Martirosyan
e3c68e9ea9
Check for imp availability (due to removal in Python 3.12) and use importlib if necessary. (#1569) 2024-10-22 16:38:54 -07:00
Adam Yoblick
462d99aa8d
Merge pull request #1705 from microsoft/fix_binskim_warnings
Fix binskim warnings
2024-10-22 16:22:54 -05:00
Tim Felgentreff
d07f941e12
Support GraalPy (#1704)
Co-authored-by: Rich Chiodo false <rchiodo@microsoft.com>
2024-10-21 13:22:10 -07:00
Adam Yoblick
281d5057cc Merge branch 'main' into fix_binskim_warnings 2024-10-21 13:12:58 -05:00
Rich Chiodo
4d86a42380
Updates from pydevd (#1706)
* Changes from pushing to pydevd

* Update some time outs to get flakey tests to pass

* Fix string failure

* String case backwards. Fixup test in pydevd

* Using callstack for exception check not sufficient

* Too restrictive on pydevd matching

* Try somethign better than just checking 'pydev'

* Retry a flakey test

* Disable flakey tests

* Another flakey test

* Increase timeout for attach

* Try upping timeout

* Up watchdog timeout

* Up some more timeouts

* Try delaying shutdown of test apps

* Don't output extra things that tests don't expect

* Fix output differences in 3.9? Not sure what that's about

* Fixup line differences in 3.9 with extra sleep

* Fix linter errors

* Fix breakpoint bugs
2024-10-21 10:17:39 -07:00
Adam Yoblick
23c5eb71ae Add binaries generated by PR check 2024-10-16 13:11:15 -05:00
Adam Yoblick
00e6434e80 Fix binskim warnings 2024-10-16 12:44:02 -05:00
Heejae Chang
39879bdeea
added native debugging section (#1696) 2024-10-10 16:42:01 -07:00
Rich Chiodo
0116f9f65e
Update CONTRIBUTING.md (#1695) 2024-10-10 14:46:00 -07:00
Rich Chiodo
178a0f4158
Directions on how to debug pydevd (#1694)
* Directions on how to debug pydevd

* Review feedback
2024-10-10 14:12:13 -07:00
Rich Chiodo
f7d5df027c
Get Python 3.13 to work (#1692)
* Get debug launch working

* Turn Cython support back on

* Fix test failures

* Fix gevent test to be skipped

* Missed a version change in pipeline

* Fix comment

* Review feedback
2024-10-10 09:03:34 -07:00
Rich Chiodo
25955a05d8
Get debug attach to work for 3.12 (#1683)
* Get debug attach to work for 3.12

* Skip flakey test and update binaries

* Fix the skip if to work correctly
2024-09-24 09:55:36 -07:00
Rich Chiodo
ae6812bdac
Pull in pydevd sys.monitoring support (#1680)
This is pulling in @fabioz's latest changes for sys.monitoring and then fixing up any issues found with the debugpy tests.

A lot of the changes were made by Fabio since the latest pull from pydevd, so I also created this PR to compare what changes I made to Fabio's baseline:
rchiodo/PyDev.Debugger#1

Meaning you really only need to look at that other PR to see what changes I made. The rest of the changes here are from Fabio or ruff doing reformating.

After this goes through, we should have sys.monitoring support in debugpy. We can decide later if we want to implement our own support as @int19h started.

Fixes #1496
2024-09-23 11:22:54 -07:00
Othman El Hammouchi
a2f80817a1
Detect whether debugger is already running and skip connecting/listening in that case (#1657) 2024-08-27 13:02:25 -07:00
Rich Chiodo
fb6158a059
Update round-robin.yml (#1653) 2024-08-15 10:24:23 -07:00
Rich Chiodo
ddcb19353d
Add round-robin issue assigner (#1650)
* Add round-robin issue assigner

* Missed Adam
2024-08-07 15:03:46 -07:00
Adam Yoblick
a68a804f7a
Merge pull request #1646 from microsoft/remove_vendored_info
remove extra dist-info folder causing issues when uploading to pypi
2024-08-05 18:01:01 -05:00
Adam Yoblick
ae01f967e6 remove extra dist-info folder causing issues when uploading to pypi 2024-08-05 17:40:29 -05:00
Adam Yoblick
dc58df149f
Merge pull request #1549 from wmvanvliet/qt6
PyQt6 support
2024-07-31 14:46:58 -05:00
Adam Yoblick
7b3dfb808d
Merge pull request #1639 from microsoft/add_entry_point
Add debugpy entry point
2024-07-31 13:46:28 -05:00
Adam Yoblick
aaab993245 fix comments and remove unneeded logic 2024-07-26 17:37:33 -05:00
Adam Yoblick
1245e8e062 fix indent bug 2024-07-26 17:00:42 -05:00
Adam Yoblick
bcab469038 Allow the user to specify debugpy path via the environment 2024-07-26 16:08:51 -05:00
Adam Yoblick
820d21e384
Merge pull request #1624 from microsoft/extra_argv_envvar
Add parsing args from environment
2024-07-26 10:07:08 -05:00
Adam Yoblick
7abb9cc537 PR Feedback 2024-07-25 16:07:17 -05:00
Adam Yoblick
0274b12d5c
PR feedback
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
2024-07-25 16:02:50 -05:00
Adam Yoblick
6e7248f172
PR feedback
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
2024-07-25 16:02:21 -05:00
Adam Yoblick
853cc05f50 add debugpy entry point 2024-07-25 15:59:49 -05:00
Rich Chiodo false
afaee41ca9 Merge remote-tracking branch 'upstream/main' into qt6 2024-07-24 13:31:41 -07:00
Adam Yoblick
bf4ce2b832 Fix bug in parser and fix unit test 2024-07-24 00:02:17 -05:00
Adam Yoblick
e3bf7a9665 target might be a pid, so we can't use strip 2024-07-23 17:32:32 -05:00
Adam Yoblick
c5259c7e3f Raise error if target is whitespace, fix test 2024-07-23 17:13:23 -05:00
Adam Yoblick
05709cfa10 remove logging no longer needed and fix a test 2024-07-23 16:29:01 -05:00
Adam Yoblick
ac37980f6f re-enable environment parsing 2024-07-22 18:19:07 -05:00
Adam Yoblick
da6a6482f1 fix broken yield 2024-07-22 18:15:29 -05:00
Adam Yoblick
382bc69a2b save work 2024-07-22 17:54:01 -05:00
Adam Yoblick
e0f2a8be98 check in to save work 2024-07-17 18:23:37 -05:00
Adam Yoblick
5b9bfaf3a8 add tests for reading switches from the environment 2024-07-17 14:45:41 -05:00
Adam Yoblick
a0a6cfbf1f Add tests for environment switches 2024-07-16 18:36:13 -05:00
Adam Yoblick
c77190f892 update docs 2024-07-16 14:51:37 -05:00
Adam Yoblick
1a9736bbe9 Update test docs 2024-07-16 14:41:00 -05:00
Adam Yoblick
f31df56792 Make sure target is set after parsing both command line and environment. Add some tests. 2024-07-16 14:40:48 -05:00
Adam Yoblick
fb14d133d3 Make some existing tests more explicit with their asserts 2024-07-15 18:19:26 -05:00
Adam Yoblick
4ba9da6087 add env var parsing to cli. Current tests pass but I need to add new ones 2024-07-15 16:34:44 -05:00
Adam Yoblick
6e8e5becb2
Merge pull request #1621 from microsoft/fix_numpy_tests
Fix test failures
2024-07-10 18:03:31 -05:00
Adam Yoblick
e58f228e92 Add retry for flaky tests, and remove 3.8 from tests 2024-07-10 17:38:20 -05:00
Adam Yoblick
ed9a632925 add missing file 2024-07-09 18:37:43 -05:00
Adam Yoblick
ff88ce330e Increase connection and attach timeouts to fix random errors on windows py312 tests 2024-07-09 18:13:18 -05:00
Adam Yoblick
df254f6aab fix broken numpy assert for 3.8 2024-07-09 16:10:42 -05:00
Adam Yoblick
16a4b9c0a6 change to Union syntax to support older python versions 2024-07-09 15:16:37 -05:00
Adam Yoblick
96e9f1e909 Fix numpy tests 2024-07-08 16:56:47 -05:00
Rich Chiodo
1d7c662a56
Add some more typing for the public api (#1619)
* Add some more typing for the public api

* Review feedback
2024-07-03 13:51:06 -07:00
Rich Chiodo
cfe3fef401
Add a blurb about where to find logging directions (#1617) 2024-07-02 13:49:06 -07:00
Adam Yoblick
a286befecd
Merge pull request #1608 from microsoft/update_macos_image
update macos image. macos-11 is no longer supported.
2024-06-25 23:30:12 -05:00
Adam Yoblick
c2fcaf7e89 update macos image. macos-11 is no longer supported. 2024-06-24 14:19:10 -05:00
Adam Yoblick
09b5af0bb7
Merge pull request #1567 from microsoft/fix_apiscan_errors
add profile flag when linking to fix apiscan errors
2024-04-19 17:08:26 -05:00
Adam Yoblick
48855b0640 Add binaries built from github actions 2024-04-17 16:53:02 -05:00
Adam Yoblick
09ba39c531 Re-add profile flag 2024-04-17 16:49:42 -05:00
Adam Yoblick
b6ce45e52d Replase binaries with ones built from github actions 2024-04-17 16:32:33 -05:00
Adam Yoblick
5cef52cbd9 revert changes to batch file, since it runs as a PR check 2024-04-17 16:26:21 -05:00
Adam Yoblick
85c26ece15 Forgot to add the built binaries 2024-04-17 16:21:40 -05:00
Adam Yoblick
5a81ad6b22 Rebuilt inject binaries with PROFILE linker flag 2024-04-17 16:18:04 -05:00
Adam Yoblick
d9ae0af1a1 Merge branch 'main' into fix_apiscan_errors 2024-04-16 18:34:17 -05:00
Adam Yoblick
2ee8168db3
Merge pull request #1566 from microsoft/codeowners
replace codeowners users with team
2024-04-16 18:33:28 -05:00
Adam Yoblick
1bebec6a62 replace codeowners users with team 2024-04-16 18:30:58 -05:00
Adam Yoblick
e5988e47b4 add profile flag when linking to fix apiscan errors 2024-04-16 18:23:18 -05:00
Marijn van Vliet
0035e83a40 Working on qt6 support. Needs further doc updates. 2024-03-28 17:48:25 +02:00
Pavel Minaev
42853a99c4 Add Python 3.12 as officially supported. 2024-01-25 14:22:43 -08:00
Pavel Minaev
b9b09e662f Fix #1408: Can no longer expand Numpy arrays to view elements
Fix regression when loading pydevd plugins for numpy, pandas, and django.

Add smoke test for numpy arrays.
2023-12-15 00:14:23 -08:00
Pavel Minaev
e9a39f7ca5 Fix #1477: namedtuple are not rendered in the variable browser as expected
Significantly increase safe repr limits for strings and collections.
2023-12-15 00:14:23 -08:00
Pavel Minaev
2888f7299c Update CODEOWNERS 2023-12-14 10:53:27 -08:00
Pavel Minaev
e62da42e43 Update pydevd attach-to-process binaries. 2023-12-14 10:53:27 -08:00
Pavel Minaev
46a02e10a2 Fix ruff command line arguments. 2023-12-13 21:40:57 -08:00
Pavel Minaev
79882c1861 Fix linker flags for attach-to-process binaries to comply with APIScan requirements. 2023-12-13 21:40:57 -08:00
Pavel Minaev
ef9a67fe15 Fix #1337: Get port info from debugpy
Send "debugpySockets" event with information about opened sockets when clients connect and whenever ports get opened or closed.
2023-10-06 09:55:52 -07:00
Adam Yoblick
7d09fb24dd
Merge pull request #1390 from microsoft/add_ruff_config 2023-09-20 14:39:51 -05:00
Adam Yoblick
131afb5a07 allow ruff to fail the build if errors are detected 2023-09-19 15:31:15 -05:00
Adam Yoblick
9cc65eb123 disable this linter error 2023-09-19 15:29:18 -05:00
Adam Yoblick
98032d8d7f add ruff section to pyproject.toml 2023-09-19 15:25:34 -05:00
Pavel Minaev
4a03787784 Don't build or test on Python 3.7 2023-09-12 11:14:55 -07:00
Pavel Minaev
cbd0c2a1c1 Fix #1379: Error while enumerating installed packages.
When logging environment info, report all errors at "info" level.
2023-09-12 10:10:49 -07:00
Pavel Minaev
5723ed6b1a Force setuptools version in tests via tox.ini as well. 2023-09-05 13:20:31 -07:00
Pavel Minaev
9e8d1033d0 Use setuptools<66 for Python 3.7 2023-09-05 13:20:31 -07:00
Pavel Minaev
3937f0d10a Use pip install -U to install setuptools. 2023-09-05 13:20:31 -07:00
Pavel Minaev
6ce72e20c8 Fix pipeline condition syntax. 2023-09-05 13:20:31 -07:00
Pavel Minaev
912bc4fe48 Add timeout for linting job. 2023-09-05 13:20:31 -07:00
Pavel Minaev
9df4bbdbfe Exclude more exceptional cases from coverage. 2023-09-05 13:20:31 -07:00
Pavel Minaev
9df16cec07 Re-enable coverage for debugpy.common.log and use comments to exclude specific lines instead. 2023-09-05 13:20:31 -07:00
Pavel Minaev
8e91dfb085 Exclude more error paths from codecov.
Exclude common/log.py from codecov as there are many debug helpers there.
2023-09-05 13:20:31 -07:00
Pavel Minaev
16d39cc173 Use setuptools<68 for Python 3.7 2023-09-05 13:20:31 -07:00
Pavel Minaev
6340818a0e Enumerate installed packages & versions in the log as part of environment info. 2023-09-05 13:20:31 -07:00
Pavel Minaev
2fcb85fdfa Reduce verbosity for successful tests. 2023-09-05 13:20:31 -07:00
Pavel Minaev
ea3904ccb6 Don't force-upgrade pip and setuptools for test runs. 2023-09-05 13:20:31 -07:00
Pavel Minaev
9997094101 Don't force-upgrade setuptools for test runs to avoid pkg_resources deprecation warning in gevent. 2023-09-05 13:20:31 -07:00
Pavel Minaev
ffec1b2db7 Fix find_namespace_packages 2023-09-05 13:20:31 -07:00
Pavel Minaev
7b985fd36b Use Black formatter only for Python files. 2023-09-05 13:20:31 -07:00
Darren Meehan
70dba8e137 GH-1230 Use find_namespace_packages() 2023-09-05 13:20:31 -07:00
Pavel Minaev
86d542e559 Fix Python version mismatch. 2023-08-28 13:14:39 -07:00
Pavel Minaev
88bf2c7827 Fix -Xfrozen_modules use in tests. 2023-08-28 13:14:39 -07:00
Pavel Minaev
119ca8e589 Add Python 3.11 to test matrix.
Use Python 3.11 for coverage runs.
2023-08-28 13:14:39 -07:00
Pavel Minaev
1a18cdc5b8 Update attach_to_process binaries. Fixes #1370 2023-08-24 12:28:32 -07:00
Pavel Minaev
85ceaf7d99 Rebuild attach_to_process binaries on changes to attach_to_process.yml. 2023-08-24 10:57:14 -07:00
Pavel Minaev
cd51305592 Fix #1370: macOS wheel tag mismatched
Build macOS attach binaries on macos-11 runner.
2023-08-24 10:57:14 -07:00
Pavel Minaev
2d6a224471 Update injected binaries and helpers for attach-to-process. 2023-08-24 10:18:50 -07:00
Pavel Minaev
f9372813f3 Run attach_to_process pipeline on PRs touching the corresponding directory. 2023-08-23 15:49:31 -07:00
Pavel Minaev
6e08ce2050 Add GitHub Action workflow to build pydevd_attach_to_process binaries. 2023-08-23 15:49:31 -07:00
Adam Yoblick
39ad5f47c5
Merge pull request #1362 from microsoft/testing_internal_pipeline 2023-08-18 14:44:22 -05:00
Adam Yoblick
2f48fc6479 Dummy commit to test internal pipeline trigger 2023-08-18 14:37:16 -05:00
Pavel Minaev
83baa6d302 Fix -Xfrozen_modules warnings in test runs on Python 3.11 and 3.12 2023-08-17 11:00:07 -07:00
Pavel Minaev
db3452db32 Use importlib.module_from_spec instead of imp.new_module (removed in Python 3.12). 2023-08-17 11:00:07 -07:00
Pavel Minaev
10aa6ffc6e Fix DeprecationWarning in Python 3.12 due to use of co_lnotab 2023-08-17 11:00:07 -07:00
Pavel Minaev
12117683e7 Unpin greenlet in tests/requirements.txt 2023-08-16 14:58:54 -07:00
Kira Bruneau
1569cc8319 Support disabling process timeouts when set to 0
Before this change, there wasn't any way to disable process timeouts,
but now you can with:

DEBUGPY_PROCESS_SPAWN_TIMEOUT=0
DEBUGPY_PROCESS_EXIT_TIMEOUT=0
2023-08-16 09:47:13 -07:00
Pavel Minaev
d642538d7b Don't assume column number to be 1, since this is no longer correct in Python 3.11. 2023-08-14 14:06:06 -07:00
Adam Yoblick
d55e351030
Merge pull request #1353 from microsoft/yaml_cleanup 2023-08-14 15:48:54 -05:00
Adam Yoblick
829957d3e1 Set linter step to continue on error 2023-08-14 15:01:16 -05:00
Adam Yoblick
8df8d343f3 make linter exit with zero, even on failures 2023-08-11 17:32:15 -05:00
Adam Yoblick
d75b1f4ec1 Cleaned up yaml using the redhat yaml linter and azure pipelines schema 2023-08-11 17:17:43 -05:00
Adam Yoblick
014cdac951 Add CI and PR triggers to coverage pipelines 2023-08-11 16:10:40 -05:00
Adam Yoblick
86a0ede4c1 Switch linter from flake8 to ruff 2023-08-11 15:13:14 -05:00
Adam Yoblick
894fd5e4f4
Merge pull request #1349 from microsoft/increase_coverage_timeouts 2023-08-10 13:43:00 -05:00
Adam Yoblick
6bb82234e2 Increase timeouts even more 2023-08-10 13:06:53 -05:00
Adam Yoblick
f22e1851ef increase coverage timeouts 2023-08-09 16:20:39 -05:00
Luciana Abud
3bd802ea2a
Merge pull request #1334 from luabud/removedeprecatedsettings
Add extensions recommendations and remove deprecated settings
2023-07-24 14:44:34 -07:00
Luciana Abud
ba9e417a14
Delete blank line 2023-07-21 11:50:37 -07:00
Luciana Abud
d73cf2226d Add extensions recommendations and remove settings 2023-07-21 11:47:48 -07:00
Adam Yoblick
3bd064e04d
Merge pull request #1319 from microsoft/fix-license-metadata 2023-07-19 15:21:07 -05:00
Graham Wheeler
6735fcb073
Merge pull request #1325 from microsoft/gramster-patch-1
Update README.md
2023-06-27 16:15:34 -07:00
Graham Wheeler
5a37633830
Update README.md
Added links to wiki pages
2023-06-27 16:15:11 -07:00
Brett Cannon
dbcc9486e4
Remove the EPL from the list of licenses
https://github.com/microsoft/debugpy/blob/main/LICENSE only lists MIT.
2023-06-20 17:20:52 -07:00
Adam Yoblick
4821077d5b
Merge pull request #1290 from microsoft/modify_codeowners 2023-05-12 15:40:30 -05:00
Adam Yoblick
9695688b80 Add myself to codeowners for PR reviews 2023-05-12 12:34:44 -05:00
Stella
9442a22e6c
Merge pull request #1279 from microsoft/StellaHuang95-patch-1
Create auto-label.yml
2023-04-24 09:52:25 -07:00
Stella
da14ef2347
Update auto-label.yml 2023-04-21 14:29:32 -07:00
Stella
267678832a
Create auto-label.yml 2023-04-20 09:36:48 -07:00
Alexandre Perez
e30c40fbca Use PyObject_VectorcallDict if _PyObject_FastCallDict is not available 2023-04-12 12:55:07 -07:00
Pavel Minaev
2f3e0bb7d5 Increase pipeline timeout for code coverage jobs. 2023-04-03 17:37:14 -07:00
Pavel Minaev
00bc5136e4 Suppress DeprecationWarning from pydevd due to pkg_resources.declare_namespace (#1230) 2023-04-03 17:37:14 -07:00
Stella
bc44eb85ff
Merge pull request #1235 from microsoft/StellaHuang95-patch-1
Create stale.yml
2023-03-13 13:54:52 -07:00
Stella
c3068fd6f6
Create stale.yml 2023-03-09 11:48:25 -08:00
Pavel Minaev
35504f83ed Work around #1230
Look for more specific text in the output to avoid false positives.
2023-03-07 12:16:58 -08:00
HeeJae Chang
34f7238e63 include "tests" 2023-03-06 15:36:33 -08:00
HeeJae Chang
de6a9cf6d6 Set up the proper execution environment so that Pylance knows the correct import root for the import statement. 2023-03-06 15:36:33 -08:00
Pavel Minaev
5601342de8 Fix #1217: Support "restart" in "terminated" event for "attach"{"listen"}
Request client to restart the adapter if "restart":true was specified in the debug configuration.
2023-02-27 11:03:34 -08:00
Pavel Minaev
e9dc3e8844 Fix #1074: Use "startDebugging" request for subprocesses
Use the request if client advertises the "supportsStartDebuggingRequest" capability.
2023-02-07 13:04:58 -08:00
Pavel Minaev
9fd3e72235 Disable PYDEVD_USE_FRAME_EVAL by default. 2023-01-19 13:14:35 -08:00
Fabio Zadrozny
6c3dca7918 Update pydevd to 2.9.5 (available with Apache lic now). 2023-01-05 13:27:00 -08:00
Fabio Zadrozny
c419d5a7fd Don't stop on logpoints with conditions. Fixes #1146 2022-12-17 07:46:44 -03:00
Fabio Zadrozny
66f85dce2d Handle OSError when listing to get path with real case. Fixes #1154 2022-12-16 08:28:10 -03:00
Pavel Minaev
ed59c6d090 Fix pass_env in tox.ini 2022-12-13 13:11:30 -08:00
Pavel Minaev
633597b1b5 Fix #1148: ModuleNotFoundError: No module named 'debugpy'
Fix #1149: UserWarning: incompatible copy of pydevd already imported

Fix formatting for sys.path entry passed to subprocesses.
2022-12-13 13:11:30 -08:00
Pavel Minaev
19ea6f2625 Fix excluded (library) path in CodeQL.yml. 2022-12-12 15:24:21 -08:00
Pavel Minaev
158cbf663c Tweak CodeQL path classifiers. 2022-12-12 15:24:21 -08:00
Pavel Minaev
69eaa61be0 Don't even try to extract pydevd for CodeQL purposes. 2022-12-12 15:24:21 -08:00
Pavel Minaev
bcf5281f29 Exclude pydevd from CodeQL 2022-12-12 15:24:21 -08:00
Fabio Zadrozny
1c79248ca6 When evaluating enable setting to None, deleting variables and using globals(). Fixes #1142 Fixes #1138 2022-12-09 07:51:49 -03:00
Fabio Zadrozny
bf5c644bc3 Don't use pydevd_find_thread_by_id unless really needed. Fixes #1129 2022-12-08 10:58:04 -03:00
Fabio Zadrozny
79b7c5634e Don't apply pandas customizations when value is requested for clipboard or repl. Fixes #1078 2022-12-02 15:10:38 -03:00
Fabio Zadrozny
9e94581915 Properly check filtering with ipython calls. Fixes #1104 2022-11-28 12:48:39 -08:00
Fabio Zadrozny
86e0a3f47a Make it possible to set DAP mode through pydevd.configure or command line arguments. 2022-11-25 09:57:24 -03:00
Fabio Zadrozny
bc9c596599 If gevent tries to disable the tracing prevent it. Fixes #1126 2022-11-19 06:47:19 -03:00
Fabio Zadrozny
53cda4e36d Some of the roots can be None in WASM builds 2022-11-19 06:47:19 -03:00
Fabio Zadrozny
45af79671f On Python 3.11 _fork_exec now needs to be monkey-patched for subprocesses. 2022-11-19 06:47:19 -03:00
Pavel Minaev
4067700ed8 Pin greenlet==1.1.3 in test dependencies due to #1126 2022-11-16 15:32:19 -08:00
Fabio Zadrozny
727d0d0608 Don't show strings inside containers as special variables. Fixes #1111 2022-11-15 18:08:51 -03:00
Fabio Zadrozny
04403ddc1c Add column information to exception tracebacks. Fixes #1099 2022-11-11 08:14:32 -03:00
Pavel Minaev
6c1c3d6cb1 Update CodeQL actions to use newer versions. 2022-11-08 16:03:53 -08:00
Fabio Zadrozny
a2a3328388 On Python 3.11, show column information on exceptions. Fixes #1099 2022-11-03 14:08:10 -03:00
Fabio Zadrozny
5f75955915 Update binaries to fix PyInt_FromLong not found in Python 3.11. Fixes #1100 2022-10-28 09:14:19 -03:00
Fabio Zadrozny
ae189da2a8 Support dealing with paths with inconsistent casing on Mac OS. Fixes #1031 2022-10-28 09:14:05 -03:00
Fabio Zadrozny
ac6465760a Socket changes for WASM. 2022-10-20 14:41:36 -03:00
Fabio Zadrozny
fc645045f0 Minor sync with pydevd. 2022-10-20 14:41:36 -03:00
Pavel Minaev
e7fb50add3 Do not use SO_REUSEADDR et all when listening on ephemeral ports (#1064) 2022-10-20 01:17:02 -07:00
Fabio Zadrozny
1d038201b3 Provide feedback/information in the debug console if attach to PID is slow. Fixes #1003 2022-10-17 07:05:09 -03:00
Janky Ferenc Nandor
46efd10d4a Fix #1081: no need to call os.setsid() on session leader when attaching
If os.setsid() raises exception then the debugger client
won't be able to attach to the remote process
2022-10-11 13:19:28 -07:00
Rich Chiodo
646d921dc1
Fix socket problem when running with Emscripten CPython build (#1077)
* SO_REUSEADDR is not supported in EMSCRIPTEN

* Review feedback, make handling SO_REUSEADDR behave like other options

* Remove accidental import

* Fix formatting
2022-10-05 13:20:17 -07:00
Pavel Minaev
7c8172e99c Fix #1018: setup.py doesn't fail if compiler is missing
Do not build pydevd extensions unless building debugpy.

Expose environment variable to control build failure mode if extensions fail to compile.
2022-10-05 12:01:08 -07:00
Rich Chiodo
94ad68968a
Merge pull request #1075 from rchiodo/rchiodo/fix_path_reporting
Fix problem when paths from eval
2022-10-04 11:27:36 -07:00
rchiodo
93f969720a Fix problem when paths from eval are none (can happen in emscripten case) 2022-10-04 10:16:45 -07:00
Fabio Zadrozny
fb40a0b002 Fixes in tests, improve message regarding slow repr to note environment variable to customize it. 2022-10-01 06:50:39 -03:00
Fabio Zadrozny
ac6f5ea6c9 Silence warning given on gevent / support django 4.1 in tests. 2022-10-01 06:50:39 -03:00
Fabio Zadrozny
30a96bf6e8 Enable pydevd to be used in DAP mode directly. WIP: #532 2022-09-29 15:15:07 -03:00
Fabio Zadrozny
01b1c7b238 Show all the items in tuples and lists. Fixes #1056 2022-09-26 15:22:17 -03:00
Fabio Zadrozny
9600483a05 Raise to 0.5s default timeout which notifies about slow access. 2022-09-26 15:22:00 -03:00
Fabio Zadrozny
349ff7337b Show chained exception frames in stack. Fixes #1042 2022-09-26 15:21:40 -03:00
Fabio Zadrozny
c300080c62 Show cause message on chained exception. Fixes #1024 2022-09-26 15:21:40 -03:00
Fabio Zadrozny
761bacebb5 When evaluating to None in repl provide empty string instead of null. Fixes #985 2022-09-26 15:21:22 -03:00
Pavel Minaev
1dc82718d1 Add test for TupleResolver + ctypes array. 2022-09-15 09:38:40 -03:00
Pavel Minaev
8d418fb3df Fix #1025: Debugger Does Not Enumerate ctypes Arrays
Use tuple resolver for ctypes.Array
2022-09-15 09:38:40 -03:00
lmbelo
1d7443e960 Changed environment configuration name from subprocessEnv to pythonEnv 2022-09-12 10:20:16 -07:00
lmbelo
849e15c6a4 Custom subprocess environment variables for Python embedded 2022-09-12 10:20:16 -07:00
Jamie Magee
c2b3d5efe2 Add $schema to cgmanifest.json 2022-09-12 10:19:01 -07:00
Fabio Zadrozny
a08da17302 Check if log.log_dir is None before enabling pydevd logging. 2022-09-09 18:34:26 -03:00
Fabio Zadrozny
8157273a28 New launch option: "onTerminate":"KeyboardInterrupt" allows for a soft-kill. Fixes #1022 2022-09-08 16:05:31 -03:00
Fabio Zadrozny
61321253e7 Use pydevd.log_to in debugpy to enable pydevd logging given the usage of debugpy.log_to. Fixes #1030 2022-09-02 08:45:20 -03:00
Fabio Zadrozny
3272dace18 Provide pydevd.log_to() to change the file to log to. WIP #1030 2022-08-27 07:07:33 -03:00
Fabio Zadrozny
ea423ae598 Make sure that the debugger is cleared after fork in non-python process. Fixes #1005 2022-08-19 09:20:37 -03:00
Pavel Minaev
e31df92e14 Update versioneer to 0.23. 2022-08-18 12:53:01 -07:00
Pavel Minaev
8b5eeee7e0 Fix #1008: Re-attaching continuously creates 'accept_worker' threads in debugpy
Don't recreate the server socket needlessly.
2022-08-15 14:32:56 -07:00
Fabio Zadrozny
71d42ed63f Support top-level async. Fixes #951 2022-08-12 09:34:42 -03:00
Rich Chiodo
6e247fb17b
Merge pull request #1009 from rchiodo/rchiodo/missed_thread_for_self_trace
Missed a thread to allow debugging
2022-08-05 13:36:31 -07:00
Rich Chiodo
cccfb954bd Missed a thread to allow debugging 2022-08-05 10:58:20 -07:00
Rich Chiodo
6c19aba462
Merge pull request #1007 from rchiodo/rchiodo/allow_adapter_debugging
Add DEBUGPY_TRACE_DEBUGPY variable to allow debugpy to debug itself
2022-08-04 16:52:02 -07:00
Rich Chiodo
10d8839a4c Review feedback 2022-08-04 16:21:39 -07:00
Rich Chiodo
83ff28006d Add DEBUGPY_TRACE_DEBUGPY variable to allow debugpy to debug itself 2022-08-04 15:34:06 -07:00
Pavel Minaev
4f6638b0a6 Fix #1001: Enable controlling shell expansion via "argsCanBeInterpretedByShell"
Fix #357: "argsExpansion" does not do what it says in VSCode

Treat non-array "args" in debug config as a request to prevent shell argument escaping and allow shell expansion.

Remove "argsExpansion".
2022-08-04 13:49:32 -07:00
Fabio Zadrozny
6b276e339c Step in/step over support for IPython. Fixes #869 2022-08-03 08:01:43 -03:00
Fabio Zadrozny
a294092d9c Properly stop at line 1 in frame eval mode. Fixes #995 2022-07-30 07:24:29 -03:00
Fabio Zadrozny
db43846a8d Properly consider that argv[0] may be None. Fixes #987 2022-07-14 15:44:25 -03:00
Fabio Zadrozny
b31dee3e79 Synchronize some minor changes from pydevd. 2022-07-14 15:44:01 -03:00
Kira Bruneau
d117b091c5 Fix compiling attach library from source 2022-07-14 13:46:21 -03:00
Fabio Zadrozny
b5072f33af Fix test_bytecode_manipulation in Python 3.10.5. Fixes #973 2022-07-09 07:19:42 -03:00
Pavel Minaev
5da7721d4d Fix #975: Properties parameter to the configure API has become required in 1.6.1 2022-07-07 14:08:20 -07:00
Fabio Zadrozny
3f325f58dc Protect against exception in linecache.getline. Fixes #969 2022-07-07 14:08:07 -07:00
Fabio Zadrozny
4f2a4568f0 Support for Python 3.11: cython. WIP #939 2022-07-06 09:17:50 -03:00
Fabio Zadrozny
161aa2683f Starting to add support for Python 3.11. WIP #939
Added support for setting tracing to different threads
along with some general fixes.

Main things missing:
- Compile with cython extensions
- Bytecode manipulation
- Frame eval mode (requires bytecode manipulation)
2022-06-30 10:41:40 -03:00
Pavel Minaev
7676e298b5 Fix #731: "externalTerminal" does not work on Linux
Do not wait for "runInTerminal" response when spawning the launcher.
2022-06-28 19:13:35 -07:00
Pavel Minaev
627bc1d647 Fix #934: Log output stuck when printing emoji to internalConsole with python
Gracefully handle encoding and write errors in the launcher when capturing output.
2022-06-22 10:29:36 -07:00
Pavel Minaev
0a9b01b008 Fix #865: Debugging through poetry drops subprocess
Handle "exited" { "pydevdReason": "processReplaced" } appropriately.

Add test for os.exec() in-place process replacement.
2022-06-09 10:44:10 -07:00
Fabio Zadrozny
6d049b73ab Auto-attach to subprocess with .zip targets. Fixes #945 2022-06-06 14:14:40 -03:00
Pavel Minaev
e94b71925a Exclude vendored pydevd from PoliCheck. 2022-05-25 14:54:33 -07:00
Pavel Minaev
b46500c5dc Mark test secrets as placeholders for CredScan compliance. 2022-05-25 14:11:38 -07:00
Pavel Minaev
f214dbb8b4 Remove unused imports. 2022-05-23 14:01:24 -07:00
Pavel Minaev
d2aa99f56d Fix docstrings not exposed on public API. 2022-05-23 14:01:24 -07:00
Pavel Minaev
ccce63e112 Remove redundant test parameter. 2022-05-23 14:01:24 -07:00
Pavel Minaev
b0b8db12a5 Add test for wait_for_client.cancel() 2022-05-23 14:01:24 -07:00
Pavel Minaev
eb126910c0 Add type annotations to public API. 2022-05-23 14:01:24 -07:00
Duprat
891bc7f88b Update handlers.py
* Remove named constant
* move test when not "noDebug": false
2022-05-23 12:39:05 -07:00
Duprat
3e90c5a903 Update handlers.py
Add "-X=frozen_modules=off" to cpython interpreter when version==3.11
2022-05-23 12:39:05 -07:00
Jan
78b030f509
Fix TypeError in NetCommandFactoryJson.make_get_thread_stack_message() (#928)
Set startFrame and levels to 0 if None to avoid TypeError
2022-05-19 16:18:26 -03:00
Fabio Zadrozny
0a40cabe6f Provide option to resolve symlinks when sending paths to the client. Fixes #743 2022-05-02 08:26:45 -03:00
giacomo
57836de416 improve code readability for sonarcloud checks 2022-05-02 00:16:19 -07:00
giacomo
644c658e75 no need to use f-string 2022-05-02 00:16:19 -07:00
giacomo
a9a170bd63 re-format with black 2022-05-02 00:16:19 -07:00
giacomo
a9ea29ca22 add tests for string to nums conversion during json parsing 2022-05-02 00:16:19 -07:00
giacomo
7597e466c4 more flexible logic that try converting str to number with all classinfo and fall back on error message when not successfull 2022-05-02 00:16:19 -07:00
giacomo
50632736bf re-format with black 2022-05-02 00:16:19 -07:00
giacomo
eb8095cbe6 add automatic conversion from string to int/float type, during type checks 2022-05-02 00:16:19 -07:00
Pavel Minaev
729c02f866 Update timeline.md 2022-05-02 00:12:51 -07:00
Pavel Minaev
7623694856 Update timeline.md 2022-05-02 00:12:51 -07:00
Fabio Zadrozny
eaadb6c681 Show warnings evaluating in repl. Fixes #774 2022-04-23 07:43:52 -03:00
Fabio Zadrozny
3d7499958c Make errors with conditional breakpoints clearer. Fixes #893 2022-04-22 07:32:51 -03:00
Fabio Zadrozny
e615771b24 Breakpoint log messages should be printed when stepping too. Fixes #705 2022-04-22 07:31:02 -03:00
Fabio Zadrozny
6174f4c4bd Don't call frame.f_locals multiple times when assigning locals after evaluation. Fixes #915 2022-04-22 07:30:04 -03:00
Fabio Zadrozny
7be59933b1 If pandas has lower defaults for repr, use them. Fixes #889 2022-04-15 14:50:15 -03:00
Fabio Zadrozny
de58062f83 Handle case where client may send files with different casing. Fixes #896 2022-04-15 07:51:47 -03:00
Pavel Minaev
87facf1378 Fix CodeQL GitHub permissions. 2022-04-13 12:24:00 -07:00
Pavel Minaev
d1e5db7d8e Use new-style super() everywhere. 2022-04-13 11:38:41 -07:00
Pavel Minaev
dd5196fbfc Blacken code. 2022-04-13 11:38:41 -07:00
Pavel Minaev
cb25e2f106 Fix version check on Python 2. 2022-04-13 11:38:41 -07:00
Pavel Minaev
3a1ecbac86 Remove more workarounds for old Python versions. 2022-04-13 11:38:41 -07:00
Pavel Minaev
a6d63ce760 Add version check. 2022-04-13 11:38:41 -07:00
Pavel Minaev
0f428178b0 Remove debugpy.compat, custom !j formatter for JSON, and related helpers. 2022-04-13 11:38:41 -07:00
Pavel Minaev
1965b47034 Get rid of fmt() and use idiomatic format() and f"" instead. 2022-04-13 11:38:41 -07:00
Pavel Minaev
98087352cb Remove code paths for unsupported Python versions. 2022-04-13 11:38:41 -07:00
Pavel Minaev
e87017e0b3 Remove redundant "from __future__ import ..." 2022-04-13 11:38:41 -07:00
Joshua Tzucker
266a19809a Fix typo in README example command
- `--config-subProcess` -> `--configure-subProcess`
2022-04-13 11:01:38 -07:00
Pavel Minaev
87ef7307a4 Update README.md 2022-04-12 16:22:04 -07:00
Pavel Minaev
f3d9eb7853 Update timeline.md 2022-04-11 16:48:07 -07:00
Fabio Zadrozny
7f3ee2b120 Fix segfault attaching debugger to a running process. Fixes #882 2022-04-11 16:17:03 -03:00
Fabio Zadrozny
7f25cb22b8 Send exit message before process is replaced. WIP #865 2022-04-09 08:31:07 -03:00
Fabio Zadrozny
1b568ab86a Re-enable frame eval mode by default. 2022-04-07 10:31:14 -07:00
Pavel Minaev
2ac9538dd5 Add debug config property "clientOS" to replace "WindowsClient" / "UnixClient" in "debugOptions". 2022-03-23 16:26:12 -07:00
Pavel Minaev
da25139b47 Increase timeout for code coverage in Windows tests. 2022-03-23 15:20:29 -07:00
Pavel Minaev
1a6c323599 Remove Python 3.6 support. 2022-03-23 15:20:29 -07:00
Pavel Minaev
fb56410a65 Clean up configs. 2022-03-23 15:20:29 -07:00
Fabio Zadrozny
5e80ce1f77 More code changes related to dropping Python 2.7. 2022-03-19 07:57:42 -03:00
Graham Wheeler
094a8fd9c8
Delete report.yml 2022-03-18 20:27:21 -07:00
Graham Wheeler
4d25af30cd
Delete fullreport.yml 2022-03-18 20:27:12 -07:00
Graham Wheeler
dc734a817f
Update fullreport.yml
Include schedule and manual triggers
2022-03-17 13:48:47 -07:00
Graham Wheeler
dcca59687c
Update report.yml
Include schedule and manual triggers
2022-03-17 13:48:06 -07:00
Graham Wheeler
9d5969a7b6
Update fullreport.yml
Fix name and make manual to test
2022-03-17 13:30:07 -07:00
Graham Wheeler
8ffb895dba
Create fullreport.yml
Add workflow for weekly full report
2022-03-17 13:28:08 -07:00
Graham Wheeler
fed292a89a
Update report.yml
Add Fabio as team member
2022-03-17 13:23:07 -07:00
Graham Wheeler
02ebfabe97
Update report.yml
Change back to scheduled reports
2022-03-17 12:18:59 -07:00
Graham Wheeler
e52a2ce2d6
Update report.yml
Push to a 'reports' branch as main is protected
2022-03-17 11:18:01 -07:00
Graham Wheeler
f2af67be7d
Update report.yml
Add explicit team and permissions.
2022-03-17 11:07:03 -07:00
Graham Wheeler
48a495c4df
Update report.yml
Make manual for testing
2022-03-17 10:02:00 -07:00
Graham Wheeler
b8f1f5c5ed
Use Github action instead of inlining everything 2022-03-16 18:16:54 -07:00
Graham Wheeler
46403a6744
Update report.yml 2022-03-15 22:36:57 -07:00
Graham Wheeler
75e8f31d11
Create report.yml
Generate daily reports from issues.
2022-03-15 21:11:03 -07:00
Fabio Zadrozny
328d4026b1 Drop support for Python 2.7. 2022-03-11 20:49:45 -03:00
Tomer Chachamu
eb7b7bb2ea Corrected versioneer install 2022-03-10 10:47:35 -08:00
Fabio Zadrozny
090e3c3ef5 Improve error messages on file validation issues. 2022-03-04 07:53:22 -03:00
Fabio Zadrozny
450fe8b201 Enable matplotlib interactive plots with QtAgg backend. Fixes #858 2022-03-03 15:37:20 -03:00
Andrii Oriekhov
356f665325 add GitHub URL for PyPy 2022-03-02 14:09:50 -08:00
Fabio Zadrozny
c5edec7708 Fix case of spurious line events with IPython. Fixes #854 2022-02-28 20:18:17 -03:00
Fabio Zadrozny
796f63e3bc Don't print twice in evaluation if output is being already redirected. Fixes #827 2022-02-26 06:40:10 -03:00
Fabio Zadrozny
6134532263 Use code object instead of (co_firstlineno, co_name, co_filename) for caching frame info. Fixes #837 Fixes #844 2022-02-25 07:39:36 -03:00
Pavel Minaev
1b8d5ab0be Remove Python 3.5 from tox.ini 2022-02-24 12:57:56 -08:00
Pavel Minaev
420a206385 Drop Python 3.5 on all platforms, and Python 3.6 on macOS. 2022-02-24 12:57:56 -08:00
Pavel Minaev
4f12b1b47f Remove Python 2.7 from supported implementations and update versions of test packages. 2022-02-24 12:57:56 -08:00
Graham Wheeler
ecb43b94d2
Update bug_report.md
Add a link to FAQ.
2022-02-14 14:32:30 -08:00
Fabio Zadrozny
f2219b88a9 Make it possible to evaluate multi-line statements which change locals. Fixes #815 Fixes #812 2022-02-04 14:39:26 -03:00
Fabio Zadrozny
0105bd92ce Mark warning messages as important. Fixes #170 2022-01-20 15:32:19 -03:00
Fabio Zadrozny
36c7fc9eaf Update cython, debug adapter protocol, pydevd tests with django 4. 2022-01-20 15:32:19 -03:00
Fabio Zadrozny
be8dd607f6 Don't show None when evaluating in repl. Fixes #678 2022-01-06 14:51:39 -08:00
Fabio Zadrozny
83b18ef703 Handle the case where only a drive is given for the translation. Fixes #770 2021-12-16 15:47:23 -03:00
Fabio Zadrozny
b1ad4d66f1 Don't use --module from the setup during monkey-patching subprocess args. Fixes #154 2021-12-11 08:00:04 -03:00
Fabio Zadrozny
a07f6e8d83 Re-enable gevent test with Python 3.10. Fixes #688 2021-12-11 07:58:15 -03:00
Pavel Minaev
baf6121065 Add tooltips for exception breakpoint filters. (#790) 2021-12-09 13:18:02 -08:00
Fabio Zadrozny
cf0d684566 Additional fixes/tests for supporting guiEventLoop. 2021-12-04 07:28:26 -03:00
chubei
043b11fd12 Add option for injecting custom GUI event loop 2021-12-04 07:28:26 -03:00
Fabio Zadrozny
fba80681ad Support newer versions of gevent / show paused greenlets (based on GEVENT_SHOW_PAUSED_GREENLETS env var). Fixes #515 2021-12-02 08:23:50 -03:00
chubei-oppen
78bbf8be83 Update CONTRIBUTING.md
The `debugAdapterPath` option should be set to `debugpy/src/debugpy/adapter`
2021-11-30 14:34:25 -08:00
Fabio Zadrozny
2a8758d18f Customize pandas representation so that it doesn't freeze anymore. Fixes #695 2021-11-19 08:09:18 -03:00
Fabio Zadrozny
30c150af91 Sync pydevd to 2.7.0. 2021-11-18 08:37:44 -03:00
Pavel Minaev
f139ed7a67 Use the same displayName for all macOS jobs, regardless of pool used. 2021-11-03 19:00:57 -07:00
Pavel Minaev
f4c8e487fb Remove unused import. 2021-11-03 19:00:57 -07:00
Pavel Minaev
fc67ea9e7d Use macOS 10.14 to run tests for older Python versions on CI. 2021-11-03 19:00:57 -07:00
Pavel Minaev
eb53282508 Switch to MacOS 11 for CI. 2021-11-03 19:00:57 -07:00
Pavel Minaev
e25fc1dcca Fix #677: Enable CI for python 3.10
Fix #689: test_django fails on py3.10

Re-enable Django tests on Python 3.10, and add it to CI runs.
2021-11-03 19:00:57 -07:00
Fabio Zadrozny
655e35642c Hide pydevd threads from threading module. Fixes #202 2021-10-29 17:52:11 -03:00
Fabio Zadrozny
ddb083cc25 Properly validate/change django/jinja2 template breakpoints lines. Fixes #213 2021-10-26 07:53:51 -03:00
Pavel Minaev
ac360f4857 Remove helper scripts for the old signed build pipeline. 2021-10-18 12:44:26 -07:00
Pavel Minaev
ef8e81bae0 Fix #752: User Uncaught Exceptions setting should be false by default 2021-10-18 12:44:17 -07:00
Fabio Zadrozny
f1ea183e25 Sync pydevd jython fix. 2021-10-18 12:40:18 -07:00
Karthik Nadig
3edb9f022f
Merge pull request #753 from karthiknadig/update-launch-json
Update launch json
2021-10-13 12:23:21 -07:00
Karthik Nadig
3e429288c8 Update launch json 2021-10-13 11:28:43 -07:00
Pavel Minaev
9ad731d3be Run macOS tests in the macOS-10.14 pool to ensure that old Python versions are still available. 2021-10-08 11:53:44 -07:00
Fabio Zadrozny
2bd30aba7c Sync pydevd 2021-10-08 06:55:29 -03:00
Fabio Zadrozny
765b64c0a4 Don't evaluate twice if an exception is raised. Fixes #742 2021-10-08 06:55:08 -03:00
Lumir Balhar
f14ba78c5c Do not install tox into tox
Having tox as a dependency in requirements files means that
it's also installed in all the tox environments.
2021-09-28 13:29:29 -07:00
Fabio Zadrozny
0a3fa3f94d User Uncaught Exceptions always shown. Fixes #724 2021-09-23 21:14:16 -03:00
Fabio Zadrozny
02f3792636 Consider that __class__ may not really be what we expect. Fixes #699 2021-09-23 21:13:57 -03:00
Fabio Zadrozny
869babbd93 Python 3.10: support for cython and frame eval mode. 2021-09-17 16:15:03 -03:00
Steve Kowalik
9d8bb3fa3c Correct pthread library name in find_library()
ctypes.util.find_library() does not require the "lib" prefix, and may
throw an exception depending on the environment, so drop the prefix
when finding it.
2021-09-16 09:48:19 -03:00
Daniel Gerigk
5dc21d67b3
Don't interrupt debugger on flask reload (#721) 2021-09-16 09:47:25 -03:00
Pavel Minaev
7cb12bed8b Fix versioneer not updating _version.py. 2021-09-09 09:58:14 -07:00
Fabio Zadrozny
fdd1f4dc38 When possible collect try..except information from source and not bytecode. 2021-09-09 10:05:57 -03:00
Pavel Minaev
3ecfee9ffd Remove usage of setup.py --abi 2021-08-30 15:03:07 -07:00
Fabio Zadrozny
59b9db9420
Python 3.10: Improve support for detecting unhandled exceptions (work in progress). (#708) 2021-08-30 09:05:49 -03:00
Pavel Minaev
77b0a59bed Filter vendored binaries based on filename, instead of a hardcoded list. 2021-08-27 12:52:58 -07:00
Pavel Minaev
68d82b02b2 Fix #155: manylinux wheels don't pass auditwheel checks
For platform-specific wheels, do not include attach-to-PID binaries for other platforms.
2021-08-27 12:52:58 -07:00
Pavel Minaev
514e54fa2b Fix non-universal wheels incorrectly having native code under purelib. (for #155) 2021-08-20 12:28:11 -07:00
Pavel Minaev
d9ca878cd2 Build attach_linux_*.so for manylinux1 using the official containers from PyPA. 2021-08-20 12:27:28 -07:00
Fabio Zadrozny
2a2c371d98
Python 3.10: support for attach to process and set tracing to other threads. (#697)
Note: Mac i386 is no longer supported for attach to process binaries.
2021-08-19 10:53:49 -03:00
Fabio Zadrozny
3207466fc3 Python 3.10 support (work in progress).
Updated bytecode library (and other minors).
2021-08-11 10:38:48 -03:00
Pavel Minaev
e59195d6a4 Fix #579: "Cannot assign requested address" error is not being propagated to VS Code 2021-08-10 13:37:40 -07:00
Pavel Minaev
3a9f7d64c4 Assorted fixes for Python 3.10 support:
Split test/requirements.txt into two different lists, one for py2, and the other for py3; update package versions in py3 list as needed to support py3.10.

Fix usage of deprecated threading functions getName(), setName(), isDaemon(), and currentThread().

Refactor test_invalid_breakpoints to be more declarative to handle Python version differences more easily and clearly, and fix it for py3.10.

Disable Django tests on py3.10 (#689).

Disable gevent tests on py3.10 (#688).
2021-08-06 07:12:13 -03:00
Pavel Minaev
0e5b8f7a7c Fix #545: Popen CREATE_BREAKAWAY_FROM_JOB in Python while debugging causes permission error (Access Denied)
Use JOB_OBJECT_LIMIT_BREAKAWAY_OK for the launcher job.

Fix error reporting in messaging when connection closes while sending a message.
2021-08-03 14:01:22 -07:00
Fabio Zadrozny
7a9b7baef7 Sync with pydevd 2021-07-30 13:59:28 -03:00
Fabio Zadrozny
202a5efbf2 Fix issue reloading relative imports. Fixes #680 2021-07-30 13:17:36 -03:00
Fabio Zadrozny
8aa184e004 Consider files in pip-global to be library files. Fixes #664 2021-07-23 13:39:56 -03:00
Fabio Zadrozny
ae22e5e0d0 Fix error starting debugging on unsupported platforms. Fixes #669 2021-07-22 13:24:38 -03:00
Fabio Zadrozny
b826f57dbb Fix issue with step into target with LOAD_METHOD. Fixes #661 2021-07-16 14:21:28 -03:00
Fabio Zadrozny
75e5058b33 Fix focus hint on function breakpoint, set supportsFunctionBreakpoints on the debugpy side. 2021-07-15 14:10:29 -03:00
Fabio Zadrozny
d7970b80ad Support function breakpoints. Fixes #468 2021-07-15 14:10:29 -03:00
Fabio Zadrozny
623c503b58 Notify when (some) required stdlib imports are shadowed. Fixes #203 2021-07-08 08:40:13 -03:00
Fabio Zadrozny
58f97a9f15 Provide heuristics for the user to provide a library to set tracing to all threads. Fixes #617
The idea is that the user will be able to compile the target libraries/executables
so that the features below work:
- tracing to all the threads
- attach to process

Users will need to compile files in the expected location with the proper <arch>
(where <arch> == platform.machine()).

In Linux the following file is needed (see linux_and_mac/compile_linux.sh):
attach_<arch>.so

In Mac the following file is needed (see linux_and_mac/compile_mac.sh):
attach_<arch>.dylib

In Windows the following files are needed (see windows/compile_windows.bat):
attach_<arch>.dll
run_code_on_dllmain_<arch>.dll
inject_dll_<arch>.exe

Note: the actual compilation should use those compile scripts as a guide
as different platforms may require different compiler flags.
2021-07-08 08:35:39 -03:00
Karthik Nadig
0b242b21b7
Merge pull request #653 from mgorny/collections-abc
Fix deprecated import for MutableMapping and MutableSet
2021-07-06 15:24:35 -07:00
Michał Górny
eef3b4ef2b Fix deprecated import for MutableMapping and MutableSet
Starting with Python 3.3, MutableMapping and MutableSet are part
of collections.abc module rather than collections.  Importing them
from the old module is deprecated and no longer works in Python 3.10.
Support both modules conditionally for best compatibility.
2021-07-02 12:31:59 +02:00
Fabio Zadrozny
02477b5ac3 Deal with __future__ imports on python -c subprocess. Fixes #642 2021-06-17 09:38:47 -03:00
Karthik Nadig
8d90ef2a45
Merge pull request #639 from fabioz/keepalive_626
Set keepalive for all debugpy sockets. Fixes #626
2021-06-07 13:08:36 -07:00
Fabio Zadrozny
b53ebf712e Set keepalive for all debugpy sockets. Fixes #626 2021-06-04 11:20:51 -03:00
Fabio Zadrozny
11b71244c8 Don't try to monkey-patch if unexpected argument types are provided. Fixes #601 2021-06-04 10:42:11 -03:00
Fabio Zadrozny
e3f6f3ad4f Fixes for PyPy. Fixes #604 2021-06-03 08:29:19 -03:00
Fabio Zadrozny
b07f372d39 Accept duplicates in env if they map to the same value. Fixes #607 2021-06-03 08:28:31 -03:00
Fabio Zadrozny
6403f1e369 Make sure _get_path_with_real_case is called with an absolute path. Fixes #620 2021-05-28 13:26:21 -03:00
Fabio Zadrozny
ab4b9691b7 Improvements to step into target. Fixes #576 2021-05-27 09:02:28 -03:00
Pavel Minaev
cbed5de015 Use django.core.signals.request_finished to exit asynchronously after serving the response. 2021-05-26 11:50:48 -07:00
Pavel Minaev
0a7f2cd67d Fix #628: Flask tests fail because werkzeug.server.shutdown is deprecated
Use @app.teardown_request to exit asynchronously after serving the response.
2021-05-26 11:50:48 -07:00
Karthik Nadig
983d14f9fd
Merge pull request #631 from karthiknadig/update-pkgs
Update pkgs
2021-05-25 13:41:46 -07:00
Karthik Nadig
edd84da7fa formatting 2021-05-24 21:04:15 -07:00
Karthik Nadig
a5ced50c13 Update build python versions on windows 2021-05-24 21:03:04 -07:00
Karthik Nadig
ddffe8cc00 Update test OS version 2021-05-24 21:03:02 -07:00
Fabio Zadrozny
e8b3f362fb Don't compare objects prior to calling __xreload_old_new__. Fixes #615 2021-05-21 14:30:36 -03:00
Fabio Zadrozny
6921731af6 Check for Python version instead of __builtin__ module in compat. Fixes #586 2021-05-21 14:30:29 -03:00
Fabio Zadrozny
35203011c9 Install matplotlib on settrace. Fixes #603 2021-05-10 07:37:52 -03:00
Fabio Zadrozny
e85fdf8ab4 Sync with pydevd 2021-05-10 07:37:17 -03:00
Fabio Zadrozny
c7bb276090 Improvements to step into target. Work in progress: #576
Description:
- Changes the structure to create a stack from the bytecode information
  so that function call names are correctly computed (this is still a work
  in progress as not all bytecode instructions are currently supported).
- Support to step into function calls inside comprehensions/generators.
- Updates the bytecode dependency to 0.12.0.
  Note: changes were done to the bytecode library to keep the bytecode offset.
2021-05-04 13:14:52 -07:00
Pavel Minaev
8ec0a316e6 Use ubuntu-latest to run Linux tests on CI.
Update apt packages before trying to install gdb.
2021-05-04 13:10:13 -07:00
Fabio Zadrozny
5c35f28473 Fix --module index on subprocess auto-attach. Fixes #533 2021-04-15 13:13:01 -03:00
Fabio Zadrozny
2ae7dc96ec Not stopping at StopAsyncIteration exception in debugger. Fixes #541 2021-03-26 15:10:09 -03:00
Karthik Nadig
511890562a
Merge pull request #573 from karthiknadig/fix-codeql
Fix codeql issues
2021-03-25 13:26:56 -07:00
Karthik Nadig
d2a735c828 Fix codeql issues 2021-03-25 13:04:55 -07:00
Fabio Zadrozny
e9834c26ad If pydevd deps cannot be imported, add itself to the PYTHONPATH. Fixes #542 2021-03-25 16:12:56 -03:00
Fabio Zadrozny
0dd74a7257 On Python 3.6 dicts retain insertion order, so, keys are no longer sorted in such cases when printing. Fixes #566 2021-03-25 14:09:35 -03:00
Fabio Zadrozny
2ebc4e71b5 Support step into target. Fixes #288 2021-03-23 08:05:55 -03:00
Fabio Zadrozny
cdc975c4fb Improve handling of name mangling. Fixes #559 2021-03-12 09:40:29 -03:00
Fabio Zadrozny
9ab891b328 Code reloading. Fixes #212 2021-03-11 10:26:51 -03:00
Fabio Zadrozny
6ee41420e6 Sync with latest pydevd changes. 2021-03-05 08:55:39 -03:00
Pavel Minaev
ed8cc0b724 Update pipelines.yaml
Increase test timeout on Windows.
2021-02-22 12:51:06 -08:00
osown
4b32a3ccdd Fix SIGINT hanndling inside debugee 2021-02-09 10:46:06 -08:00
Fabio Zadrozny
cbcfe221d7 Add object id if variable name would be duplicate. Fixes #148 2021-01-23 07:33:48 -03:00
Fabio Zadrozny
c265d74bc5 Smaller Linux .so. Fixes #169 2021-01-18 07:09:52 -03:00
Fabio Zadrozny
44a07d030e Properly translate line in Goto Target. Fixes #150 2021-01-18 07:08:27 -03:00
Fabio Zadrozny
aa36155221 Show full stack trace on exception with __cause__ or __context__. Fixes #391 2021-01-14 11:02:08 -03:00
Fabio Zadrozny
59ee2edc49 Disable tracing at thread shutdown. Fixes #492 2021-01-05 07:09:16 -03:00
Fabio Zadrozny
218248080e Sync pydevd -> debugpy 2021-01-05 07:08:25 -03:00
Fabio Zadrozny
f118b101eb Silence warnings when accessing user attributes. Fixes #190 2021-01-05 07:07:34 -03:00
Karthik Nadig
6116bc1582
Merge pull request #501 from karthiknadig/nuget1
Update nuget packages
2021-01-04 23:35:24 -08:00
Karthik Nadig
2191ce56b2 Update nuget packages 2020-12-14 12:16:19 -08:00
Fabio Zadrozny
58ef3da9aa Provide full string when evaluating clipboard. Fixes #110 2020-12-12 08:17:03 -03:00
Fabio Zadrozny
a7282e9232 Properly handle sys.exit() as sys.exit(0). Fixes #489 2020-12-12 07:07:03 -03:00
Fabio Zadrozny
e573ea771a Support having no sys.argv in debugger. Fixes #473 2020-12-12 06:48:55 -03:00
Fabio Zadrozny
93516395a9 Handle invalid socket options. Fixes #491 2020-12-12 06:45:52 -03:00
Fabio Zadrozny
f9b54cdcd9 Support running non-ascii files on Python 2. Fixes #206 2020-12-10 08:52:28 -03:00
Fabio Zadrozny
2341614e14 Fix issue with conflicting path mapping. Fixes #482 2020-12-04 16:48:53 -03:00
Fabio Zadrozny
9e2c8106bd Properly dealing with -X python vmargs. Fixes #455 2020-12-04 16:48:42 -03:00
Fabio Zadrozny
ac05dab62b Support module with __file__=None. Fixes #475 2020-12-03 09:38:59 -03:00
Fabio Zadrozny
609af83703 Sync with latest pydevd. 2020-12-03 09:37:29 -03:00
Fabio Zadrozny
d0bb24a8ab Run pydevd tests on github actions. Fixes #471 2020-11-24 07:07:37 -03:00
Pavel Minaev
7d2a7a2b11 Fix #463: Enable overriding "pythonPath" in the launcher
Add "debugLauncherPython" debug config property to customize Python interpreter used to spawn the launcher.
2020-11-11 11:13:09 -08:00
Fabio Zadrozny
c6dc935fd8 Support frame eval in Python 3.9. Fixes #441 2020-11-07 06:51:43 -03:00
Fabio Zadrozny
75bb3a751d Fix issue where file is detected as library code when it shouldn't. Fixes #457 2020-11-07 06:50:05 -03:00
Karthik Nadig
7aa6f4c83a Re-compile binaries 2020-11-05 07:50:59 -03:00
fritzmark
70d4f5bcb7 Update README.md
Corrected pid parameter usage.
2020-11-05 07:45:44 -03:00
fritzmark
b613ec84a0 Update README.md
Fixed spelling.
2020-11-05 07:45:44 -03:00
schulz3m
97b1a61c91 Added subProcess parameter to cli docu 2020-11-05 07:45:44 -03:00
Fabio Zadrozny
ad09acb2c9 Set the default monkeypatching of qt to None. Fixes #362 2020-11-05 07:44:50 -03:00
Fabio Zadrozny
7485e76385 Native thread tracing in frame eval mode. Fixes #444 2020-11-05 07:44:50 -03:00
Karthik Nadig
75944e5968
Merge pull request #449 from karthiknadig/pypi1
Add 3.9 classifier
2020-10-31 00:08:35 -07:00
Karthik Nadig
18bd28165b Add 3.9 classifier 2020-10-26 20:36:40 -07:00
Pavel Minaev
34e1e405a7 Fix pydevd_attach_to_process Windows build script to locate VC++ using vswhere.
Update pydevd_attach_to_process binaries.
2020-10-26 11:39:43 -07:00
Pavel Minaev
5384d23743 Fix #93: null values not supported in "env" 2020-10-26 11:22:12 -07:00
Pavel Minaev
1727a3e109 Fix #330: Unable to debug pythonw apps on macOS
In the launcher, use "python" instead of sys.executable to spawn the debuggee.

Update test for "python" / "pythonPath" / "pythonArgs" to use a helper script to assert the use of a custom Python binary; and test -B instead of -v to minimize test log size and run time.
2020-10-23 16:44:56 -07:00
Pavel Minaev
1de5526317 Rename master -> main. 2020-10-21 09:33:31 -07:00
Fabio Zadrozny
fb7926fd80 Keep protocol correct on a fork after a subprocess. Fixes #264 2020-10-17 08:45:53 -03:00
Fabio Zadrozny
9cda8e0515 Check if function return is None to consider exception unhandled on return. Fixes #404 2020-10-14 07:20:56 -03:00
Fabio Zadrozny
74c4915099 Update binary dependencies to support Python 3.9. Fixes #384 2020-10-14 07:18:10 -03:00
Pavel Minaev
49919cd40e Add a feature flag for userUnhandled exception filter. 2020-09-30 11:56:03 -07:00
Fabio Zadrozny
3d472df2d6 Show the full stack trace on user unhandled exceptions. Fixes #399 2020-09-30 10:20:52 -07:00
Pavel Minaev
d68a17170c Re-enable attach by socket on macOS + Python 3.6 (per #1967). 2020-09-25 13:41:24 -07:00
Pavel Minaev
6e1c7567d2 Fix #81: Subprocess always waits for client to attach
Unblock subprocesses for which no notification could be sent to the client.
2020-09-25 13:41:24 -07:00
Fabio Zadrozny
cf65911a7a Sync latest pydevd -> debugpy. 2020-09-23 16:51:52 -03:00
Fabio Zadrozny
18c0c282ff Support case sensitive folders on Windows. Fixes #200 2020-09-23 09:54:43 -03:00
Fabio Zadrozny
8368d89e91 Update third party notices for bytecode. 2020-09-23 08:26:29 -03:00
Fabio Zadrozny
71432a2c2d Fix issues in bytecode generation on frame eval mode. Fixes #346 2020-09-23 08:26:29 -03:00
Karthik Nadig
a7666a2ba4
Merge pull request #417 from karthiknadig/bin2
Compile with Qspectre
2020-09-21 22:41:59 -07:00
Karthik Nadig
e0c2d14f09
Merge pull request #409 from karthiknadig/bin1
Update nuget packages.
2020-09-21 13:44:44 -07:00
Karthik Nadig
b6ebb18313 Build binaries with new compiler flags 2020-09-21 13:23:14 -07:00
Karthik Nadig
5f08b324e8 Compile with Qspectre 2020-09-21 13:19:16 -07:00
Karthik Nadig
97d9d39c64 Revert "Compile with Qspectre"
This reverts commit 57d3eadc8a.
2020-09-21 13:16:16 -07:00
Karthik Nadig
57d3eadc8a Compile with Qspectre 2020-09-21 13:13:14 -07:00
bob-white
7859f5c4b2
Makes the listen process configurable. (#387)
Allow the use of "python" in debugpy.configure() for attach scenarios.
2020-09-21 12:54:56 -07:00
Pavel Minaev
562afbcde0 Fix #414: test_invalid_breakpoints fails on Python 3.9
Adjust expected line numbers in test to reflect Python changes.
2020-09-21 12:24:47 -07:00
Karthik Nadig
b81ca97d96 Update nuget packages. 2020-09-11 01:42:30 -07:00
Karthik Nadig
d3cb68f21a
Merge pull request #406 from karthiknadig/bin1
More compiler tweaks
2020-09-10 15:08:18 -07:00
Karthik Nadig
b8f45cec71
Merge pull request #393 from karthiknadig/cg1
Update TPN and add cgmenifest
2020-09-10 12:42:04 -07:00
Karthik Nadig
c071686879
Update src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/run_code_on_dllmain.cpp 2020-09-10 12:41:40 -07:00
Karthik Nadig
78bd26571e More compiler tweaks 2020-09-05 19:18:32 -07:00
Karthik Nadig
e4d9baf1fa
Merge pull request #403 from karthiknadig/bin1
Build with control flow guard
2020-09-05 16:52:37 -07:00
Karthik Nadig
c595b6f07c Add warning flag for compilations. 2020-09-05 15:54:00 -07:00
Karthik Nadig
793097ff40
Merge pull request #402 from karthiknadig/poli1
Fix policheck issues
2020-09-05 15:24:12 -07:00
Karthik Nadig
74ea719786 Build with control flow guard 2020-09-03 20:13:00 -07:00
Karthik Nadig
c0243ca32e Fix policheck issues 2020-09-03 17:04:18 -07:00
Pavel Minaev
14ca4f07d1 Fix #351: Python warnings in debugger code
Don't use inspect.getargspec on Python 2.

Close log file objects on exit.

Close os.devnull file objects on exit.

Close the listener socket used to get endpoints info from adapter.

Fix invalid escape sequences.

Run tests with Python warnings treated as errors.

Fix Django deprecation warning in test web app.

Work around pytest issues caused spaces in test names.
2020-09-03 01:32:58 -07:00
Karthik Nadig
1a93e56734 Add cgmanifest listing vendored dependencies 2020-08-28 12:42:58 -07:00
Karthik Nadig
d69beaf987 Remove untangle from TPN 2020-08-28 12:42:39 -07:00
Fabio Zadrozny
7512ab01d6 Fix issue collecting try..except information. Fixes #374 2020-08-27 20:59:45 -03:00
Pavel Minaev
6200c1db4f Fix os.environ encoding on Python 2.7. 2020-08-26 10:09:19 -07:00
Pavel Minaev
677fef79d1 Disable frame-eval by default to work around #346. 2020-08-26 10:09:19 -07:00
Fabio Zadrozny
44b01c8165 Fix issue inspecting numpy array. Fixes #378 2020-08-20 16:18:51 -03:00
910 changed files with 181498 additions and 85193 deletions

4
.CodeQL.yml Normal file
View file

@ -0,0 +1,4 @@
path_classifiers:
library:
- "src/debugpy/_vendored/pydevd"

View file

@ -11,16 +11,19 @@ omit =
data_file = coverage/.coverage
[report]
exclude_lines =
# Have to re-enable the standard pragma.
pragma: no cover
exclude_also =
# __repr__ is mostly used for error messages.
def __repr__
# Asserts and error conditions.
raise AssertionError
raise NotImplementedError
raise TypeError
raise ValueError
raise AttributeError
raise RuntimeError
raise ComponentNotAvailable
raise messaging.MessageHandlingError
\.isnt_valid\(
\.cant_handle\(

View file

@ -11,3 +11,4 @@ exclude =
dist,
versioneer.py,
src/debugpy/_vendored/pydevd

2
.gitattributes vendored
View file

@ -1 +1 @@
debugpy/_version.py export-subst
src/debugpy/_version.py export-subst

5
.github/CODEOWNERS vendored
View file

@ -4,7 +4,4 @@
# in the repository, i.e. bar/baz will match /bar/baz and /foo/bar/baz.
# The default owners for everything that is not overridden by specific patterns below.
* @int19h @karthiknadig
# Order is important: the last matching pattern overrides all the preceding ones.
/src/ptvsd/_vendored/pydevd/ @fabioz
* @microsoft/pyrx-admins

View file

@ -4,6 +4,8 @@ about: Create a report to help us improve
---
Before creating a new issue, please check the [FAQ](https://github.com/microsoft/debugpy/wiki/FAQ) to see if your question is answered there.
## Environment data
- debugpy version: XXX (run `import debugpy; print(debugpy.__version__)` if uncertain)

39
.github/workflows/auto-label.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Auto-label when user responds
permissions:
issues: write
on:
issue_comment:
types: [created]
env:
TRIAGERS: '["int19h","karthiknadig","ericsnowcurrently","fabioz", "gramster", "StellaHuang95", "AdamYoblick"]'
jobs:
run-check:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'waiting for response') && !contains(github.event.issue.labels.*.name, 'user responded')
steps:
- name: Add/Remove labels when user responds
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload;
const commentAuthor = payload.comment.user.login;
const isTeamMember = ${{ env.TRIAGERS }}.includes(commentAuthor);
if (!isTeamMember) {
const issue_number = payload.issue.number;
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
name: 'waiting for response'
});
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
labels: ['user responded']
});
}

View file

@ -4,49 +4,30 @@ on:
push:
pull_request:
schedule:
- cron: '0 19 * * 0'
- cron: "0 19 * * 0"
permissions:
security-events: write
jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest and windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v3
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

79
.github/workflows/round-robin.yml vendored Normal file
View file

@ -0,0 +1,79 @@
name: round-robin
permissions:
issues: write
on:
issues:
types: [opened]
jobs:
assignIssue:
name: Assign Issue to Someone
runs-on: ubuntu-latest
if: github.repository == 'microsoft/debugpy' && github.event.action == 'opened' && !contains( github.event.issue.labels.*.name, 'skip-reassign')
steps:
- name: Find last assigned
id: assigned
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
const issue = await github.rest.issues.get({
issue_number: 1649,
owner: context.repo.owner,
repo: context.repo.repo
});
return (issue.data.assignees && issue.data.assignees[0].login) || '';
- name: Dump last assigned
env:
LAST_ASSIGNED: ${{ steps.assigned.outputs.result }}
run: echo "$LAST_ASSIGNED"
- uses: lee-dohm/team-rotation@v1
with:
last: ${{ steps.assigned.outputs.result }}
include: bschnurr heejaechang StellaHuang95 rchiodo gramster
id: rotation
- name: Dump next in rotation
env:
NEXT_ROTATION: ${{ steps.rotation.outputs.next }}
run: echo "$NEXT_ROTATION"
- name: Assign to next person
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addAssignees({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ['${{ steps.rotation.outputs.next }}']
})
- name: Give it the label 'needs repro'
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['needs repro']
})
- name: Save assignment to state
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
await github.rest.issues.removeAssignees({
issue_number: 1649,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ['${{ steps.assigned.outputs.result }}']
});
github.rest.issues.addAssignees({
issue_number: 1649,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ['${{ steps.rotation.outputs.next }}']
})

34
.github/workflows/stale.yml vendored Normal file
View file

@ -0,0 +1,34 @@
# This workflow closes issues that have been labeled as 'waiting for response' and had no activity for 30 days.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Close stale 'waiting for response' issues
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: "0 0 * * *"
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
days-before-issue-close: 0
close-issue-message: "This issue was closed because it has been stalled for 30 days with no activity. If the issue still persists, please reopen with the information requested. Thanks."
any-of-labels: "waiting for response"

10
.gitignore vendored
View file

@ -5,11 +5,14 @@ __pycache__/
# C extensions
*.so
*.dylib
*.dll
*.pdb
*.exe
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
@ -22,7 +25,9 @@ pip-wheel-metadata/
sdist/
var/
wheels/
wheelhouse/
*.egg-info/
*.dist-info/
.installed.cfg
*.egg
@ -84,7 +89,7 @@ celerybeat-schedule
*.sage.py
# virtualenv
.venv
.venv*
venv/
ENV/
@ -105,6 +110,7 @@ ENV/
.vs/
.vscode/*
!.vscode/launch.json
!.vscode/extensions.json
# PyDev
.project

View file

@ -1,37 +0,0 @@
language: python
dist: xenial
sudo: required
cache: pip
python:
- "2.7"
- "3.8"
addons:
apt:
packages:
- gdb
stages:
- lint
- test
jobs:
include:
- stage: lint
python: "3.8"
install:
- pip install -U pip setuptools flake8
script:
- flake8
before_install:
- sudo sysctl kernel.yama.ptrace_scope=0
install:
- pip install -U pip setuptools tox tox-travis
script:
- tox -- -n4 -v
env:
- TOX_SKIP_ENV=.*-cov

8
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,8 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.flake8",
"ms-python.black-formatter"
]
}

29
.vscode/launch.json vendored
View file

@ -11,7 +11,7 @@
"console": "integratedTerminal",
"program": "${file}",
"logToFile": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Launch: module",
@ -21,19 +21,16 @@
"module": "${fileBasenameNoExtension}",
"cwd": "${fileDirname}",
"logToFile": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Launch: code",
"type": "python",
"request": "launch",
"console": "integratedTerminal",
"code": [
"import runpy",
"runpy.run_path(r'${file}')",
],
"code": ["import runpy", "runpy.run_path(r'${file}')"],
"logToFile": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Attach: connect",
@ -41,10 +38,10 @@
"request": "attach",
"connect": {
"port": 5678,
"host": "127.0.0.1",
"host": "127.0.0.1"
},
"logToFile": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Attach: listen",
@ -52,24 +49,26 @@
"request": "attach",
"listen": {
"port": 5678,
"host": "127.0.0.1",
"host": "127.0.0.1"
},
"logToFile": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
//"restart": true,
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Attach: PID",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"request": "launch",
"console": "integratedTerminal",
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter",
"purpose": ["debug-test"],
"debugAdapterPath": "${workspaceFolder}/src/debugpy/adapter"
}
]
}
}

View file

@ -1,8 +1,7 @@
# Contributing to `debugpy`
[![Build Status](https://ptvsd.visualstudio.com/_apis/public/build/definitions/557bd35a-f98d-4c49-9bc9-c7d548f78e4d/1/badge)](https://ptvsd.visualstudio.com/ptvsd/ptvsd%20Team/_build/index?definitionId=1)
[![Build Status](https://travis-ci.org/Microsoft/ptvsd.svg?branch=master)](https://travis-ci.org/Microsoft/ptvsd)
[![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/Microsoft/ptvsd/master/LICENSE)
[![Build Status](https://dev.azure.com/debugpy/debugpy/_apis/build/status/debugpy-test-automation?branchName=main)](https://dev.azure.com/debugpy/debugpy/_build/latest?definitionId=1&branchName=main)
[![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/microsoft/debugpy/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/ptvsd.svg)](https://pypi.org/project/ptvsd/)
@ -25,7 +24,7 @@ The following tools are required to work on debugpy:
- [Black](https://black.readthedocs.io/en/stable/)
- [tox](https://tox.readthedocs.io/en/latest/)
We recommend using [Visual Studio Code](https://code.visualstudio.com/) with the (Python extension)[https://marketplace.visualstudio.com/items?itemName=ms-python.python] to work on debugpy, but it's not a requirement. A workspace file, [debugpy.code-workspace], is provided for the convenience of VSCode users, and sets it up to use the other tools listed above properly.
We recommend using [Visual Studio Code](https://code.visualstudio.com/) with the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) to work on debugpy, but it's not a requirement. A workspace file, [debugpy.code-workspace], is provided for the convenience of VSCode users, and sets it up to use the other tools listed above properly.
Tools that are Python packages should be installed via pip corresponding to the Python 3 installation. On Windows:
```
@ -66,7 +65,7 @@ On Linux or macOS:
```
.../debugpy$ python3 -m tox
```
This will perform a full run with the default settings. A full run will run tests on Python 2.7 and 3.5-3.8, and requires all of those to be installed. If some versions are missing, or it is desired to skip them for a particular run, tox can be directed to only run tests on specific versions with `-e`. In addition, the `--developer` option can be used to skip the packaging step, running tests directly against the source code in `src/debugpy`. This should only be used when iterating on the code, and a proper run should be performed before submitting a PR. On Windows:
This will perform a full run with the default settings. A full run will run tests on Python 2.7 and 3.5-3.8, and requires all of those to be installed. If some versions are missing, or it is desired to skip them for a particular run, tox can be directed to only run tests on specific versions with `-e`. In addition, the `--develop` option can be used to skip the packaging step, running tests directly against the source code in `src/debugpy`. This should only be used when iterating on the code, and a proper run should be performed before submitting a PR. On Windows:
```
...\debugpy> py -m tox -e py27,py37 --develop
```
@ -75,9 +74,173 @@ On Linux or macOS:
.../debugpy$ python3 -m tox -e py27,py37 --develop
```
You can run all tests in a single file using a specified python version, like this:
```
...\debugpy> py -m tox --develop -e py312 -- ".\tests\debugpy\server\test_cli.py"
```
You can also specify a single test, like this:
```
...\debugpy> py -m tox --develop -e py312 -- ".\tests\debugpy\server\test_cli.py::test_duplicate_switch"
```
The tests are run concurrently, and the default number of workers is 8. You can force a single worker by using the `-n0` flag, like this:
```
...\debugpy> py -m tox --develop -e py312 -- -n0 ".\tests\debugpy\server\test_cli.py"
```
### Running tests without tox
While tox is the recommended way to run the test suite, pytest can also be invoked directly from the root of the repository. This requires packages in tests/test_requirements.txt to be installed first.
While tox is the recommended way to run the test suite, pytest can also be invoked directly from the root of the repository. This requires packages in tests/requirements.txt to be installed first.
Using a venv created by tox in the '.tox' folder can make it easier to get the pytest configuration correct. Debugpy needs to be installed into the venv for the tests to run, so using the tox generated .venv makes that easier.
#### Keeping logs on test success
There's an internal setting `debugpy_log_passed` that if set to true will not erase the logs after a successful test run. Just search for this in the code and remove the code that deletes the logs on success.
#### Adding logging
Using `pydevd_log.debug` you can add logging just about anywhere in the pydevd code. However this code won't be called if CYTHON support is enabled without recreating the Cython output. To temporarily disable CYTHON support, look for `CYTHON_SUPPORTED` and make sure it's set to False
## Updating pydevd
Pydevd (at src/debugpy/_vendored/pydevd) is a subrepo of https://github.com/fabioz/PyDev.Debugger. We use the [subrepo](https://github.com/ingydotnet/git-subrepo) to have a copy of pydevd inside of debugpy
In order to update the source, you would:
- git checkout -b "branch name"
- python subrepo.py pull
- git push
- Fix any debugpy tests that are failing as a result of the pull
- Create a PR from your branch
You might need to regenerate the Cython modules after any changes. This can be done by:
- Install Python latest (3.14 as of this writing)
- pip install cython 'django>=1.9' 'setuptools>=0.9' 'wheel>0.21' twine
- On a windows machine:
- set FORCE_PYDEVD_VC_VARS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
- in the pydevd folder: python .\build_tools\build.py
## Pushing pydevd back to PyDev.Debugger
If you've made changes to pydevd (at src/debugpy/_vendored/pydevd), you'll want to push back changes to pydevd so as Fabio makes changes to pydevd we can continue to share updates.
To do this, you would:
- Create a fork of https://github.com/fabioz/PyDev.Debugger
- Switch back to your debugpy clone
- python subrepo.py branch -m "pydevd branch you want to create"
- git push -f https://github.com/"your fork"/PyDev.Debugger subrepo/src/debugpy/_vendored/pydevd:$(pydevd branch you want to create)
- Create a PR from that branch
- Get Fabio's buyoff on the changes
### Setting up pydevd to be testable
Follow these steps to get pydevd testable:
- create an environment to test. The list of stuff in your environment is outlined [here](https://github.com/fabioz/PyDev.Debugger/blob/6cd4d431e6a794448f33a73857d479149041500a/.github/workflows/pydevd-tests-python.yml#L83).
- set PYTHONPATH=. (make sure you don't forget this part, otherwise a lot of tests will fail)
### Testing pydevd and fixing test failures
Pydevd has a lot more tests on execution than debugpy. They reside in all of the `test` folders under the root. The majority of the execution tests are in the `tests_python` folder.
You run all of the tests with (from the root folder):
- python -m pytest -n auto -rfE
That will run all of the tests in parallel and output any failures.
If you want to just see failures you can do this:
- python -m pytest -n auto -q
That should generate output that just lists the tests which failed.
```
=============================================== short test summary info ===============================================
FAILED tests_python/test_debugger.py::test_path_translation[True] - AssertionError: TimeoutError (note: error trying to dump threads on timeout).
FAILED tests_python/test_debugger.py::test_remote_debugger_multi_proc[False] - AssertionError: TimeoutError
FAILED tests_python/test_debugger.py::test_path_translation[False] - AssertionError: TimeoutError (note: error trying to dump threads on timeout).
======================== 3 failed, 661 passed, 169 skipped, 77 warnings in 319.05s (0:05:19) =========================
```
With that you can then run individual tests like so:
- python -m pytest -n auto tests_python/test_debugger.py::test_path_translation[False]
That will generate a log from the test run.
Logging the test output can be tricky so here's some information on how to debug the tests.
#### Running pydevd tests inside of VS code
You can also run the pydevd tests inside of VS code using the test explorer (and debug the pytest code). To do so, set PYTHONPATH=. and open the `src/debugpy/_vendored/pydevd` folder in VS code. The test explorer should find all of the pydevd tests.
#### How to add more logging
The pydevd tests log everything to the console and to a text file during the test. If you scroll up in the console, it should show the log file it read the logs from:
```
Log on failure:
-------------------- C:\Users\rchiodo\AppData\Local\Temp\pytest-of-rchiodo\pytest-77\popen-gw3\test_path_translation_and_sour0\pydevd_debug_file_23524.32540.txt ------------------
```
If you want to add more logging in order to investigate something that isn't working, you simply add a line like so in the code:
```python
pydevd_log.debug("Some test logging", frame, etc)
```
Make sure if you add this in a module that gets `cythonized`, that you turn off `Cython` support as listed above. Otherwise you'll have to regen the C code or you won't actually see your new log output.
#### How to use logs to debug failures
Investigating log failures can be done in multiple ways.
If you have an existing test failing, you can investigate it by running the test with the main branch and comparing the results. To do so you would:
- Clone the repo a second time
- Change the code in `tests_python/debugger_unittest.py` so that the test prints out logs on success too (by default it only logs the output on a failure)
- Run the failing test in the second clone
- Run the failing test in your original clone (with the --capture=tee-sys so that it outputs the log)
- Diff the results by finding the log file name in the output and diffing those two files
- Add more logging around where the differences first appear
- Repeat running and diffing
If you're adding a new test or just trying to figure out what the expected log output is, you would look at the failing test to see what steps are expected in the output. Here's an example:
```python
def test_case_double_remove_breakpoint(case_setup):
with case_setup.test_file("_debugger_case_remove_breakpoint.py") as writer:
breakpoint_id = writer.write_add_breakpoint(writer.get_line_index_with_content("break here"))
writer.write_make_initial_run()
hit = writer.wait_for_breakpoint_hit()
writer.write_remove_breakpoint(breakpoint_id)
writer.write_remove_breakpoint(breakpoint_id) # Double-remove (just check that we don't have an error).
writer.write_run_thread(hit.thread_id)
writer.finished_ok = True
```
That test would have events correlating to:
- Initialization (all debug sessions have this)
- Setting breakpoints on a specific line
- Breakpoint event being hit
- Setting breakpoints to empty
- Setting breakpoints to empty
- Continue event
Those would show up in the log like so:
Breakpoint command
```
0.00s - Received command: CMD_SET_BREAK 111 3 1 python-line C:\Users\rchiodo\source\repos\PyDev.Debugger\tests_python\resources\_debugger_case_remove_breakpoint.py 7 None None None
```
In order to investigate a failure you'd look for the CMDs you expect and then see where the CMDs deviate. At that point you'd add logging around what might have happened next.
## Using modified debugpy in Visual Studio Code
To test integration between debugpy and Visual Studio Code, the latter can be directed to use a custom version of debugpy in lieu of the one bundled with the Python extension. This is done by specifying `"debugAdapterPath"` in `launch.json` - it must point at the root directory of the *package*, which is `src/debugpy` inside the repository:
@ -85,7 +248,32 @@ To test integration between debugpy and Visual Studio Code, the latter can be di
```json5
{
"type": "python",
"debugAdapterPath": ".../debugpy/src/debugpy",
"debugAdapterPath": ".../debugpy/src/debugpy/adapter",
...
}
```
## Enabling logging in VS code
See the directions here:
https://github.com/microsoft/debugpy/wiki/Enable-debugger-logs
## Debugging native code (Windows)
To debug the native components of `debugpy`, such as `attach.cpp`, you can use Visual Studio's native debugging feature.
Follow these steps to set up native debugging in Visual Studio:
1. Open Visual Studio and go to `Debug` > `Options` > `Symbols`.
2. Check the option **Search for all module symbols unless excluded**. This ensures that Visual Studio loads the necessary symbols (PDB files) for all modules, including dynamically loaded ones.
3. Click **OK** to close the options dialog.
4. Run your Python script from the command line, for example: `python ./main.py`
5. In Visual Studio, go to `Debug` > `Attach to Process`.
6. From the list of processes, select the appropriate Python process. Be sure to choose the correct process, especially if you're using a virtual environment. You can verify this by checking the command line associated with each process in the **Task Manager**.
7. Under **Attach to**, choose either **Automatic: Native code** or explicitly select **Native** to attach as a native debugger.
8. Click **Attach**.
9. Open the native source file you want to debug, such as `attach.cpp`, and set breakpoints where necessary (e.g., at `DoAttach`).
10. Trigger the loading of the DLL, such as by attaching `debugpy` to the Python process (refer to `Attach: PID` in `debugpy`'s `launch.json` for more details on attaching to the process).
11. Once the DLL is loaded, Visual Studio will automatically load the associated PDB files, and your breakpoints should become active.
12. When the breakpoint is hit, you can debug the native code as you would in any debug session.
If you need to step into the Python code during the debug session, you can download the Python source code from [python.org](https://www.python.org/downloads/source/). Unzip it to a folder, and when Visual Studio prompts for the source location, point it to the folder where you extracted the Python source. Ensure that the Python version matches the interpreter used to run your script (e.g., `python ./main.py`).

View file

@ -1,7 +1,9 @@
# debugpy - a debugger for Python
[![Build Status](https://dev.azure.com/debugpy/debugpy/_apis/build/status/debugpy-test-automation?branchName=master)](https://dev.azure.com/debugpy/debugpy/_build/latest?definitionId=1&branchName=master)
[![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/microsoft/debugpy/master/LICENSE)
An implementation of the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) for Python 3.
[![Build Status](https://dev.azure.com/debugpy/debugpy/_apis/build/status/debugpy-test-automation?branchName=main)](https://dev.azure.com/debugpy/debugpy/_build/latest?definitionId=1&branchName=main)
[![GitHub](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/microsoft/debugpy/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/debugpy.svg)](https://pypi.org/project/debugpy/)
[![PyPI](https://img.shields.io/pypi/pyversions/debugpy.svg)](https://pypi.org/project/debugpy/)
@ -13,9 +15,10 @@
| Linux | ![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/debugpy/debugpy/3) |
| Mac | ![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/debugpy/debugpy/4) |
This debugger implements the Debug Adapter Protocol: [debugProtocol.json](https://github.com/Microsoft/vscode-debugadapter-node/blob/master/debugProtocol.json)
## `debugpy` CLI Usage
For full details, see the [Command Line Reference](https://github.com/microsoft/debugpy/wiki/Command-Line-Reference).
### Debugging a script file
To run a script file with debugging enabled, but without waiting for the client to attach (i.e. code starts executing immediately):
```console
@ -52,7 +55,17 @@ The following command injects the debugger into a process with a given PID that
-m debugpy --listen localhost:5678 --pid 12345
```
### Ignoring subprocesses
The following command will ignore subprocesses started by the debugged process.
```console
-m debugpy --listen localhost:5678 --pid 12345 --configure-subProcess False
```
## `debugpy` Import usage
For full details, see the [API reference](https://github.com/microsoft/debugpy/wiki/API-Reference).
### Enabling debugging
At the beginning of your script, import debugpy, and call `debugpy.listen()` to start the debug adapter, passing a `(host, port)` tuple as the first argument.
```python
@ -76,14 +89,14 @@ debugpy.wait_for_client() # blocks execution until client is attached
```
### `breakpoint()` function
In Python 3.7 and above, `debugpy` supports the standard `breakpoint()` function. Use `debugpy.breakpoint()` function for similar behavior and compatibility with older versions of Python. If the debugger is attached when either of these functions is invoked, it will pause execution on the calling line, as if it had a breakpoint set. If there's no client attached, the functions do nothing, and the code continues to execute normally.
Where available, debugpy supports the standard `breakpoint()` function for programmatic breakpoints. Use `debugpy.breakpoint()` function to get the same behavior when `breakpoint()` handler installed by debugpy is overridden by another handler. If the debugger is attached when either of these functions is invoked, it will pause execution on the calling line, as if it had a breakpoint set. If there's no client attached, the functions do nothing, and the code continues to execute normally.
```python
import debugpy
debugpy.listen(...)
while True:
...
breakpoint() # or debugpy.breakpoint() on 3.6 and below
breakpoint() # or debugpy.breakpoint()
...
```

View file

@ -28,5 +28,5 @@ If you want to debug library files, you have to disable `justMyCode` in `launch.
When filing an issue, make sure you do the following:
- Check existing issues for the same problem (also see the "Known Issues" section above for widespread problems).
- Follow instructions in [this](https://github.com/microsoft/debugpy/blob/master/.github/ISSUE_TEMPLATE/bug_report.md) template for filing a bug report.
- Follow instructions in [this](https://github.com/microsoft/debugpy/blob/main/.github/ISSUE_TEMPLATE/bug_report.md) template for filing a bug report.
- Include any debugger logs that you may have. See [here](https://github.com/microsoft/debugpy#debugger-logging) for instructions on how to enable logging.

View file

@ -1,18 +1,37 @@
# This pipeline is used to run unit test code coverage against debugpy public repo.
# Trigger ci builds for commits into master and any release branches
trigger:
branches:
include:
- main
- release/*
# Trigger pr builds for commits into master and any release branches
# Ignore draft PR's
pr:
branches:
include:
- main
- release/*
drafts: "false"
variables:
architecture: "x64"
python.version: "3.8"
architecture: "x64"
python.version: "3.11"
jobs:
- job: 'Coverage'
timeoutInMinutes: 15
pool:
name: Azure Pipelines
demands: java
vmImage: "ubuntu-18.04"
steps:
- script: |
sudo apt-get --yes install gdb
sudo sysctl kernel.yama.ptrace_scope=0
displayName: 'Install gdb'
- job: "Coverage"
timeoutInMinutes: "60"
pool:
name: Azure Pipelines
demands: java
vmImage: "ubuntu-latest"
steps:
- script: |
sudo apt-get update
sudo apt-get --yes install gdb
sudo sysctl kernel.yama.ptrace_scope=0
displayName: "Install gdb"
- template: "templates/coverage.yml"
- template: "templates/coverage.yml"

View file

@ -1,17 +1,34 @@
# This pipeline is used to run unit test code coverage against debugpy public repo.
# Trigger ci builds for commits into master and any release branches
trigger:
branches:
include:
- main
- release/*
# Trigger pr builds for commits into master and any release branches
# Ignore draft PR's
pr:
branches:
include:
- main
- release/*
drafts: "false"
variables:
architecture: "x64"
python.version: "3.8"
architecture: "x64"
python.version: "3.11"
jobs:
- job: 'Coverage'
timeoutInMinutes: 15
pool:
name: Azure Pipelines
demands: java
vmImage: "macOS-10.15"
steps:
- script: |
ulimit -Sn 8192
displayName: 'Increase file descriptor limit'
- job: "Coverage"
timeoutInMinutes: "60"
pool:
name: Azure Pipelines
demands: java
vmImage: "macOS-latest"
steps:
- script: "ulimit -Sn 8192"
displayName: "Increase file descriptor limit"
- template: "templates/coverage.yml"
- template: "templates/coverage.yml"

View file

@ -1,119 +1,250 @@
# This pipeline is used to run PR validation and CI builds against the debugpy public repo.
# Seperate internal pipelines are used for generating wheels, signing, and releasing to pypi.org
# Trigger ci builds for commits into master and any release branches
trigger:
branches:
include:
- main
- release/*
# Trigger pr builds for commits into master and any release branches
pr:
branches:
include:
- '*'
variables:
architecture: "x64"
architecture: x64
PYDEVD_ATTACH_TO_PROCESS: src/debugpy/_vendored/pydevd/pydevd_attach_to_process
jobs:
- job: "Lint"
timeoutInMinutes: 15
displayName: "Lint"
pool: { vmImage: "ubuntu-18.04" }
stages:
variables:
python.version: "3.8"
- stage: Lint
jobs:
- job: Lint
timeoutInMinutes: 5
steps:
- template: "templates/use_python.yml"
pool:
vmImage: ubuntu-latest
- script: |
python3 -m pip install -U flake8
python3 -m pip install -U git+https://github.com/karthiknadig/flake8reports
displayName: "Setup flake8"
variables:
python.version: "3.9"
- script: |
python3 -m flake8 --format=junit --output-file=$(Build.ArtifactStagingDirectory)/lint-flake8.xml
displayName: "Run flake8"
steps:
- task: "PublishTestResults@2"
condition: "always()"
- template: templates/use_python.yml
# Install and run ruff
# See https://github.com/astral-sh/ruff and https://beta.ruff.rs/docs/
- script: python3 -m pip install -U ruff
displayName: Install ruff
# Run linter
- script: python3 -m ruff check --output-format=junit --output-file=$(Build.ArtifactStagingDirectory)/lint-ruff.xml .
displayName: Run ruff
# Publish results, even on failure
- task: PublishTestResults@2
displayName: Publish linting results
inputs:
testRunTitle: "$(Agent.JobName)"
testResultsFiles: "lint-*.xml"
searchFolder: "$(Build.ArtifactStagingDirectory)"
displayName: "Publish linting results"
testRunTitle: $(Agent.JobName)
testResultsFiles: lint-*.xml
searchFolder: $(Build.ArtifactStagingDirectory)
condition: always()
- job: "Test_Linux"
- stage: Pydevd
jobs:
- job: Build
displayName: Build
strategy:
matrix:
Windows:
image: windows-latest
contents: |
*.exe
*.dll
*.pdb
script: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)/windows/compile_windows.bat
workingDirectory: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)/windows
macOS:
image: macOS-latest
contents: |
*.dylib
script: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)/linux_and_mac/compile_mac.sh
workingDirectory: $(System.DefaultWorkingDirectory)
Linux:
image: ubuntu-latest
contents: |
*.so
script: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)/linux_and_mac/compile_linux.sh
workingDirectory: $(System.DefaultWorkingDirectory)
pool:
vmImage: $(image)
steps:
# Clean up old binaries
- task: DeleteFiles@1
displayName: Clean up old binaries
inputs:
SourceFolder: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)
Contents: $(contents)
# Build pydevd binaries
- script: $(script)
displayName: Build pydevd binaries
workingDirectory: $(workingDirectory)
# copy pydevd binaries
- task: CopyFiles@2
displayName: Copy pydevd binaries
inputs:
SourceFolder: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)
Contents: $(contents)
TargetFolder: $(Build.ArtifactStagingDirectory)
# Publish pydevd binaries
- task: PublishBuildArtifacts@1
displayName: Publish pydevd binaries
inputs:
artifactName: pydevd binaries
pathToPublish: $(Build.ArtifactStagingDirectory)
- stage: Test
dependsOn: Pydevd
jobs:
- job: Tests_Linux
displayName: Tests - Linux
timeoutInMinutes: 30
displayName: "Tests - Linux"
pool: { vmImage: "ubuntu-18.04" }
pool:
vmImage: ubuntu-latest
strategy:
matrix:
py27:
python.version: "2.7"
py35:
python.version: "3.5"
py36:
python.version: "3.6"
py37:
python.version: "3.7"
py38:
python.version: "3.8"
matrix:
py39:
python.version: 3.9
py310:
python.version: 3.10
py311:
python.version: 3.11
py312:
python.version: 3.12
py313:
python.version: 3.13
py314:
python.version: 3.14.0-rc.2
steps:
- script: |
sudo apt-get --yes install gdb
sudo sysctl kernel.yama.ptrace_scope=0
displayName: "Setup gdb"
- template: "templates/use_python.yml"
- script: |
sudo apt-get update
sudo apt-get --yes install gdb
sudo sysctl kernel.yama.ptrace_scope=0
displayName: Setup gdb
- template: "templates/run_tests.yml"
- template: templates/use_python.yml
- job: "Test_MacOS"
# download pydevd binaries
- download: current
displayName: Download pydevd binaries
artifact: pydevd binaries
# copy pydevd binaries
- task: CopyFiles@2
displayName: Copy pydevd binaries
inputs:
SourceFolder: $(Pipeline.Workspace)/pydevd binaries
TargetFolder: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)
- template: templates/run_tests.yml
- job: Tests_Mac
timeoutInMinutes: 30
displayName: "Tests - macOS"
pool: { vmImage: "macOS-10.15" }
displayName: Tests - macOS
pool:
vmImage: macOS-latest
strategy:
matrix:
py27:
python.version: "2.7"
py35:
python.version: "3.5"
py36:
python.version: "3.6"
py37:
python.version: "3.7"
py38:
python.version: "3.8"
matrix:
py39:
python.version: 3.9
py310:
python.version: 3.10
py311:
python.version: 3.11
py312:
python.version: 3.12
py313:
python.version: 3.13
py314:
python.version: 3.14.0-rc.2
steps:
- script: |
ulimit -Sn 8192
displayName: "Increase file descriptor limit"
- template: "templates/use_python.yml"
- script: ulimit -Sn 8192
displayName: Increase file descriptor limit
- script: |
python -m ensurepip --user
displayName: "Bootstrap pip"
- template: templates/use_python.yml
- template: "templates/run_tests.yml"
- script: python -m ensurepip --user
displayName: Bootstrap pip
- job: "Test_Windows"
timeoutInMinutes: 30
displayName: "Tests - Windows"
pool: { vmImage: "windows-2019" }
# download pydevd binaries
- download: current
displayName: Download pydevd binaries
artifact: pydevd binaries
# copy pydevd binaries
- task: CopyFiles@2
displayName: Copy pydevd binaries
inputs:
SourceFolder: $(Pipeline.Workspace)/pydevd binaries
TargetFolder: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)
- template: templates/run_tests.yml
- job: Test_Windows
timeoutInMinutes: 40
displayName: Tests - Windows
pool:
vmImage: windows-latest
strategy:
matrix:
py27:
python.version: "2.7"
py35:
python.version: "3.5"
py36:
python.version: "3.6"
py37:
python.version: "3.7"
py38:
python.version: "3.8"
py27_32:
python.version: "2.7"
architecture: "x86"
py38_32:
python.version: "3.8"
architecture: "x86"
matrix:
py39:
python.version: 3.9
py39_32:
python.version: 3.9
architecture: x86
py310:
python.version: 3.10
py311:
python.version: 3.11
py312:
python.version: 3.12
py313:
python.version: 3.13
py314:
python.version: 3.14.0-rc.2
steps:
- template: "templates/use_python.yml"
- template: "templates/run_tests.yml"
- template: templates/use_python.yml
# download pydevd binaries
- download: current
displayName: Download pydevd binaries
artifact: pydevd binaries
# copy pydevd binaries
- task: CopyFiles@2
displayName: Copy pydevd binaries
inputs:
SourceFolder: $(Pipeline.Workspace)/pydevd binaries
TargetFolder: $(Build.SourcesDirectory)/$(PYDEVD_ATTACH_TO_PROCESS)
- template: templates/run_tests.yml

Binary file not shown.

View file

@ -0,0 +1,3 @@
<PoliCheckExclusions>
<Exclusion Type="FolderPathFull">_vendored\pydevd</Exclusion>
</PoliCheckExclusions>

View file

@ -1,37 +1,35 @@
steps:
- template: "use_python.yml"
- template: "use_python.yml"
- script: |
python -m pip install -U pip setuptools tox
displayName: 'Setup Python packages'
- script: "python -m pip install tox"
displayName: "Setup Python packages"
- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'SonarCloud-debugpy'
organization: microsoft
scannerMode: CLI
extraProperties: |
sonar.python.coverage.reportPaths=$(Build.SourcesDirectory)/coverage/coverage.xml
sonar.projectKey=microsoft_debugpy
- task: SonarCloudPrepare@1
displayName: "Prepare analysis on SonarCloud"
inputs:
SonarCloud: "SonarCloud-debugpy"
organization: microsoft
scannerMode: CLI
extraProperties: |
sonar.python.coverage.reportPaths=$(Build.SourcesDirectory)/coverage/coverage.xml
sonar.projectKey=microsoft_debugpy
- script: |
python -m tox --develop -e py38-cov -- --cov-report=html --cov-report=xml -vv
displayName: 'Coverage Run'
- script: "python -m tox --develop -e py311-cov -- --cov-report=html --cov-report=xml -vv"
displayName: "Coverage Run"
- task: SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
- task: SonarCloudAnalyze@1
displayName: "Run Code Analysis"
- task: SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
inputs:
pollingTimeoutSec: '300'
- task: SonarCloudPublish@1
displayName: "Publish Quality Gate Result"
inputs:
pollingTimeoutSec: "300"
- task: PublishCodeCoverageResults@1
displayName: 'Publish Coverage Report'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/coverage/coverage.xml'
reportDirectory: '$(Build.SourcesDirectory)/coverage/html'
failIfCoverageEmpty: true
condition: always()
- task: PublishCodeCoverageResults@1
displayName: "Publish Coverage Report"
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: "$(Build.SourcesDirectory)/coverage/coverage.xml"
reportDirectory: "$(Build.SourcesDirectory)/coverage/html"
failIfCoverageEmpty: true
condition: always()

View file

@ -1,28 +1,39 @@
steps:
- script: |
python -m pip install -U pip setuptools tox
displayName: "Setup Python packages"
- script: python -m pip install tox
displayName: Setup Python packages
- pwsh: |
$toxEnv = '$(python.version)'
if (-not $toxEnv.startsWith('pypy')) {
$toxEnv = 'py' + $toxEnv.Replace('.', '')
}
echo 'tox environment: $toxEnv'
python -m tox -e $toxEnv -- -vv --junitxml=$(Build.ArtifactStagingDirectory)/tests.xml --debugpy-log-dir=$(Build.ArtifactStagingDirectory)/logs tests
displayName: "Run tests using tox"
- pwsh: |
$raw = '$(python.version)'
if ($raw.StartsWith('pypy')) {
# For PyPy keep original pattern stripping dots after first two numeric components if needed later.
$toxEnv = 'py' + ($raw -replace '^pypy(\d+)\.(\d+).*$','$1$2')
}
else {
# Extract major.minor even from prerelease like 3.14.0-rc.2 -> 3.14
$mm = [regex]::Match($raw,'^(\d+)\.(\d+)')
if (-not $mm.Success) { throw "Unable to parse python.version '$raw'" }
$toxEnv = 'py' + $mm.Groups[1].Value + $mm.Groups[2].Value
}
Write-Host "python.version raw: $raw"
Write-Host "Derived tox environment: $toxEnv"
python -m tox -e $toxEnv -- --junitxml=$(Build.ArtifactStagingDirectory)/tests.xml --debugpy-log-dir=$(Build.ArtifactStagingDirectory)/logs tests
displayName: Run tests using tox
env:
DEBUGPY_PROCESS_SPAWN_TIMEOUT: 60
DEBUGPY_LAUNCH_TIMEOUT: 60
- task: "PublishBuildArtifacts@1"
condition: "failed()"
inputs:
artifactName: "Test logs"
pathToPublish: "$(Build.ArtifactStagingDirectory)/logs"
displayName: "Publish test logs"
- task: PublishBuildArtifacts@1
displayName: Publish test logs
inputs:
artifactName: Test logs
pathToPublish: $(Build.ArtifactStagingDirectory)/logs
condition: failed()
- task: PublishTestResults@2
displayName: Publish test results
inputs:
testRunTitle: $(Agent.JobName)
testResultsFiles: tests.xml
searchFolder: $(Build.ArtifactStagingDirectory)
condition: always()
- task: "PublishTestResults@2"
condition: "always()"
inputs:
testRunTitle: "$(Agent.JobName)"
testResultsFiles: "tests.xml"
searchFolder: "$(Build.ArtifactStagingDirectory)"
displayName: "Publish test results"

View file

@ -1,6 +1,7 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "$(python.version)"
architecture: "$(architecture)"
displayName: "Use Python $(python.version) $(architecture)"
- task: UsePythonVersion@0
inputs:
versionSpec: $(python.version)
architecture: $(architecture)
allowUnstable: true
displayName: Use Python $(python.version) $(architecture)

View file

@ -1,13 +1,31 @@
# This pipeline is used to run unit test code coverage against debugpy public repo.
# Trigger ci builds for commits into master and any release branches
trigger:
branches:
include:
- main
- release/*
# Trigger pr builds for commits into master and any release branches
# Ignore draft PR's
pr:
branches:
include:
- main
- release/*
drafts: "false"
variables:
architecture: "x64"
python.version: "3.8"
architecture: "x64"
python.version: "3.11"
jobs:
- job: 'Coverage'
timeoutInMinutes: 20
pool:
name: Azure Pipelines
demands: java
vmImage: "windows-2019"
steps:
- template: "templates/coverage.yml"
- job: "Coverage"
timeoutInMinutes: "60"
pool:
name: Azure Pipelines
demands: java
vmImage: "windows-latest"
steps:
- template: "templates/coverage.yml"

1
build/git-subrepo/.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text eol=lf

View file

@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = https://github.com/ingydotnet/git-subrepo.git
branch = 0.4.1
commit = a04d8c2e55c31931d66b5c92ef6d4fe4c59e3226
parent = b341532bdd2eacaddca2d9c63421ef3ac9d3d239
method = merge
cmdver = 0.4.1

38
build/git-subrepo/.rc Normal file
View file

@ -0,0 +1,38 @@
#!bash
#------------------------------------------------------------------------------
#
# This is the `git-subrepo` initialization script.
#
# This script turns on the `git-subrepo` Git subcommand, its manpages and TAB
# completion for the *Bash* and *zsh* shells.
#
# Just add a line like this to your shell startup configuration:
#
# source /path/to/git-subrepo/.rc
#
#------------------------------------------------------------------------------
if [[ ${BASH_VERSION} ]]; then
if [[ ${BASH_VERSINFO[0]} -lt 4 ]] ; then
echo "The git-subrepo command requires that 'Bash 4+' is installed."
echo "It doesn't need to be your shell, but it must be in your PATH."
if [[ $OSTYPE == darwin* ]]; then
echo "You appear to be on macOS."
echo "Try: 'brew install bash'."
echo "This will not change your user shell, it just installs 'Bash 5.x'."
fi
return
fi
fi
[[ -n ${ZSH_VERSION-} ]] &&
GIT_SUBREPO_ROOT=$0 ||
GIT_SUBREPO_ROOT=$BASH_SOURCE
[[ $GIT_SUBREPO_ROOT =~ ^/ ]] ||
GIT_SUBREPO_ROOT=$PWD/$GIT_SUBREPO_ROOT
export GIT_SUBREPO_ROOT=$(cd "$(dirname "$GIT_SUBREPO_ROOT")"; pwd)
export PATH=$GIT_SUBREPO_ROOT/lib:$PATH
export MANPATH=$GIT_SUBREPO_ROOT/man:$MANPATH
source "$GIT_SUBREPO_ROOT/share/enable-completion.sh"

View file

@ -0,0 +1,31 @@
language: shell
matrix:
include:
- name: Git 2.21 on Ubuntu Xenial
dist: xenial
language: shell
# === This will need to removed when Travis drops support ===
- name: Git 2.15.1 on Ubuntu Trusty
dist: trusty
language: shell
- name: Git on Mac
os: osx
osx_image: xcode8.3
addons:
homebrew:
packages:
- bash
update: true
script:
# NOTE: we have to make sure we're on a branch (rather than on a detached HEAD)
# because tests rely on it.
- git checkout -b travis-ci-dummy-branch-name
- GIT_COMMITTER_NAME=Bob
GIT_COMMITTER_EMAIL=bob@blob.net
GIT_AUTHOR_NAME='Bob Blob'
GIT_AUTHOR_EMAIL=bob@blob.net
PROVEOPT=-v make test

110
build/git-subrepo/Changes Normal file
View file

@ -0,0 +1,110 @@
---
version: 0.4.1
date: Thu Jan 9 17:11:21 CST 2020
- Fix Bash version error messages and add to .rc
- Nicer YAML formatting in .travis.yml
- Wrap a long line
- Update the docs
- Force `make update` to always update docs
- Don't use XXX in perl stuff
- Add testing on MacOS
- Remove conflicting -C from install -d commands.
- Update version requirement documentation
- Correct error message in branch
- Use topo-order in subrepo branch
- Make “git subrepo clean -f ...” delete refs correctly
- Fix #410 Push empty repositories with recent git versions
- Make subrepo work when run in a worktree
- Simplify finding subrepos
- Ask git to find the .gitrepo files
- Doc: fix sentence repetition
- Fix typos
- Fixed typo
- Travis CI not checking out a branch.
---
version: 0.4.0
date: Thu Nov 8 12:26:38 CET 2018
changes:
- Fix #325 Do not squash main repo commits
- Improve error message for worktree handling
- Make version checking portable. #307
- #307, improve version check
- #307, update version requirement
- Fix part #308, Add stderr output if commands fail
- Fix #306: Add check to prevent following commits with no .gitrepo
- Remove dry-run flag as it's not implemented. Make sure branch --force delete worktree
- Fix #296, Replace --first-parent with --ancestry-path
- Fix #291, specify Trusty host to get new 2.x git
- Fix #258, add --no-tags to git fetch
- Test that no remotes are created during clone
- #257 Remove remote creation to avoid problems with fetch --all
- (origin/issue/150_to_0.4.0) Fix remove-worktree, remove unused parameters
- Regenerate completion files
- filter-branch operation should not be done on HEAD
- Cleanup push and add hint to push directly after pull
- Simplify cleanup and add worktree to status
- Add --method option to init/clone, add a 'config' command
- Updated unit tests to support the new logic
- Use 'git worktree' for merge/rebase
- Update docs to reflect how things should work
- Make it possible to specify commit messages
- Redesign, trash the tree hash approach and use merges instead
- Add release branches to travis-ci
- Add --method option to init/clone, add a 'config' command
- Detect multiple pulls, use -u flag to decide
- Don't reuse previous commit message when using --all
- Update the docs for pull and push
- Update error messages when failing merge/rebase
- Fix env var bug in test/push.t
- Do not overwrite author information
---
version: 0.3.1
date: Tue Jan 3 23:08:56 PST 2017
changes:
- Updated release for homebrew
- Fix #192
---
version: 0.3.0
date: Wed Dec 2 19:19:43 PST 2015
changes:
- Fix issue #98 and host of others (89, 91, 95, 96)
- Adds support for the merge-base command
- Adds stability to many commands
- Command completion updates
- Rename `init` to `.rc`
- @grimmySwe++ @dzzh++ @jrosdahl++ @perlpunk++
---
version: 0.2.3
date: Sun Aug 9 13:44:22 PDT 2015
changes:
- Fix issues #75 and #76
---
version: 0.2.2
date: Wed Jul 22 09:45:13 PDT 2015
changes:
- Added the `init` subcommand
- Applied doc fixes
---
version: 0.2.1
date: Sat Mar 28 07:52:22 PDT 2015
changes:
- Allows subrepo clone to clone to an empty branch; fixes #26.
- Refs in status
- Empty parent set to 'none' in .gitrepo file.
- Bug fixes
---
version: 0.2.0
date: Sat Jan 24 06:22:05 PST 2015
changes:
- Massive overhaul
- .gitrepo files remain the same so backwards compatible
- Introduce the branch and commit subcommands
- The checkout subcommand goes away
- Operations work much smoother like normal Git flow
- Much more testing
- Better doc
---
version: 0.1.0
date: Fri Feb 21 12:25:53 2014 -0800
changes:
- First version

509
build/git-subrepo/Intro.pod Normal file
View file

@ -0,0 +1,509 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.48.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Introducing Git Subrepos
There is a new git command called C<subrepo> that is meant to be a solid
alternative to the C<submodule> and C<subtree> commands. All 3 of these
commands allow you to include external repositories (pinned to specific
commits) in your main repository. This is an often needed feature for project
development under a source control system like Git. Unfortunately, the
C<submodule> command is severely lacking, and the C<subtree> command (an
attempt to make things better) is also very flawed. Fortunately, the
C<subrepo> command is here to save the day.
This article will discuss how the previous commands work, and where they go
wrong, while explaining how the new C<subrepo> command fixes the issues.
It should be noted that there are 3 distinct roles (ways people use repos)
involved in discussing this topic:
=over
=item * B<owner> — The primary author and repo owner
=item * B<collaborators> — Other developers who contribute to the repo
=item * B<users> — People who simply use the repo software
=back
=head2 Introducing C<subrepo>
While the main point is to show how subrepo addresses the shortcomings
of submodule and subtree, I'll start by giving a quick intro to the
subrepo command.
Let's say that you have a project repo called 'freebird' and you want to have
it include 2 other external repos, 'lynyrd' and 'skynyrd'. You would do the
following:
git clone git@github.com/you/freebird
cd freebird
git subrepo clone git@github.com/you/lynyrd ext/lynyrd
git subrepo clone git@github.com/you/skynyrd ext/skynyrd --branch=1975
What these commands do (at a high level) should be obvious. They "clone" (add)
the repos content into the subdirectories you told them to. The details of
what is happening to your repo will be discussed later, but adding new
subrepos is easy. If you need to update the subrepos later:
git subrepo pull ext/lynyrd
git subrepo pull ext/skynyrd --branch=1976
The lynyrd repo is tracking the upstream master branch, and you've changed the
skynyrd subrepo to the 1976 branch. Since these subrepos are owned by 'you',
you might want to change them in the context of your freebird repo. When
things are working, you can push the subrepo changes back:
git subrepo push ext/lynyrd
git subrepo push ext/skynyrd
Looks simple right? It's supposed to be. The intent of C<subrepo> is to do the
right things, and to not cause problems.
Of course there's more to it under the hood, and that's what the rest of this
article is about.
=head2 Git Submodules
Submodules tend to receive a lot of bad press. Here's some of it:
=over
=item * L<http://ayende.com/blog/4746/the-problem-with-git-submodules>
=item * L<http://somethingsinistral.net/blog/git-submodules-are-probably-not-the-answer/>
=item * L<http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/>
=back
A quick recap of some of the good and bad things about submodules:
Good:
=over
=item * Use an external repo in a dedicated subdir of your project.
=item * Pin the external repo to a specific commit.
=item * The C<git-submodule> command is a core part of the Git project.
=back
Bad:
=over
=item * Users have to know a repo has submodules.
=item * Users have to get the subrepos manually.
=item * Pulling a repo with submodules won't pull in the new submodule changes.
=item * A submodule will break if the referenced repo goes away.
=item * A submodule will break if a forced push removes the referenced commit.
=item * Can't use different submodules/commits per main project branch.
=item * Can't "try out" a submodule on alternate branch.
=item * Main repo can be pushed upstream pointing to unpushed submod commits.
=item * Command capability differs across Git versions.
=item * Often need to change remote url, to push submodule changes upstream.
=item * Removing or renaming a submodule requires many steps.
=back
Internally, submodules are a real mess. They give the strong impression of
being bolted on, well after Git was designed. Some commands are aware of the
existence of submodules (although usually half-heartedly), and many commands
are oblivious. For instance the git-clone command has a C<--recursive> option
to clone all subrepos, but it's not a default, so you still need to be aware
of the need. The git-checkout command does nothing with the submodules, even
if they are intended to differ across branches.
Let's talk a bit about how submodules are implemented in Git. Information
about them is stored in 3 different places (in the top level repo directory):
=over
=item * C<.gitmodules>
=item * C<.git/config>
=item * C<.git/modules> — The submodule repo's meta data (refs/objects)
=back
So some of the information lives in the repo history (.gitmodules), but other
info (.git/) is only known to the local repo.
In addition, the submodule introduces a new low level concept, to the
commitI<tree>blob graph. Normally a git tree object points to blob (file)
objects and more tree (directory) objects. Submodules have tree objects point
to B<commit> objects. While this seems clever and somewhat reasonable, it also
means that every other git command (which was built on the super clean Git
data model) has to be aware of this new possibility (and deal with it
appropriately).
The point is that, while submodules are a real need, and a lot of work has
gone into making them work decently, they are essentially a kludge to the Git
model, and it is quite understandable why they haven't worked out as well as
people would expect.
NOTE: Submodules I<are> getting better with each release of Git, but it's
still an endless catch up game.
=head2 Git Subtrees
One day, someone decided to think different. Instead of pointing to external
repos, why not just include them into the main repo (but also allow them to be
pulled and pushed separately as needed)?
At first this may feel like a wasteful approach. Why keep other repos
physically inside your main one? But if you think about it abstractly, what's
the difference? You want your users and collaborators to have all this code
because your project needs it. So why worry about how it happens? In the end,
the choice is yours, but I've grown very comfortable with this concept and
I'll try to justify it well. I should note that the first paragraph of the
C<submodule> doc suggests considering this alternative.
The big win here is that you can do this using the existing git model. Nothing
new is added. You are just adding commits to a history. You can do it
different on every branch. You can merge branches sensibly.
The git-subtree command seems to have been inspired by Git's subtree merge
strategy, which it uses internally, and possibly got its name from. A subtree
merge allows you to take a completely separate Git history and make it be a
subdirectory of your repo.
Adding a subtree was the easy part. All that needed to be done after that was
to figure out a way to pull upstream changes and push local ones back
upstream. And that's what the C<git-subtree> command does.
So what's the problem with git-subtree then?
Well unfortunately, it drops a few balls. The main problems come down to an
overly complicated commandline UX, poor collaborator awareness, and a fragile
and messy implementation.
Good:
=over
=item * Use an external repo in a dedicated subdir of your project.
=item * Pin the external repo to a specific commit.
=item * Users get everything with a normal clone command.
=item * Users don't need to know that subtrees are involved.
=item * Can use different submodules/commits per main project branch.
=item * Users don't need the subtree command. Only owners and collaborators.
=back
Bad:
=over
=item * The remote url and branch info is not saved (except in the history).
=item * Owners and collaborators have to enter the remote for every command.
=item * Collaborators aren't made aware that subtrees are involved.
=item * Pulled history is not squashed by default.
=item * Creates a messy historical view. (See below)
=item * Bash code is complicated.
=item * Only one test file. Currently is failing.
=back
As you can see, subtree makes quite a few things better, but after trying it
for a while, the experience was more annoying than submodules. For example,
consider this usage:
$ git subtree add --squash --prefix=foo git@github.com:my/thing mybranch
# weeks go by…
$ git subtree pull --squash --prefix=foo git@github.com:my/thing mybranch
# time to push local subtree changes back upstream
$ git subtree push --prefix=foo git@github.com:my/thing mybranch
The first thing you notice is the overly verbose syntax. It's justified in the
first command, but in the other 2 commands I really don't want to have to
remember what the remote and branch are that I'm using.
Moreover, my collaborators have no idea that subtrees are involved, let alone
where they came from.
Consider the equivalent subrepo commands:
$ git subrepo clone git@github.com:my/thing foo -b mybranch
$ git subrepo pull foo
$ git subrepo push foo
Collaborators see a file called 'foo/.gitrepo', and know that the subdir is a
subrepo. The file contains all the information needed by future commands
applied to that subrepo.
=head2 Git Subrepos
Now is a good time to dive into the techinical aspects of the C<subrepo>
command, but first let me explain how it came about.
As you may have surmised by now, I am the author of git-subrepo. I'd used
submodules on and off for years, and when I became aware of subtree I gave it
a try, but I quickly realized its problems. I decided maybe it could be
improved. I decided to write down my expected commandline usage and my ideals
of what it would and would not do. Then I set off to implement it. It's been a
long road, but what I ended up with was even better than what I wanted from
the start.
Let's review the Goods and Bads:
Good:
=over
=item * Use an external repo in a dedicated subdir of your project.
=item * Pin the external repo to a specific commit.
=item * Users get everything with a normal clone command.
=item * Users don't need to know that subrepos are involved.
=item * Can use different submodules/commits per main project branch.
=item * Meta info is kept in an obvious place.
=item * Everyone knows when a subdir is a subrepo.
=item * Commandline UX is minimal and intuitive.
=item * Pulled history is always squashed out locally.
=item * Pushed history is kept intact.
=item * Creates a clean historical view. (See below)
=item * Bash code is very simple and easy to follow.
=item * Comprehensive test suite. Currently passing on travis:
=back
=for html
<a href="https://travis-ci.org/ingydotnet/git-subrepo"><img src="https://travis-ci.org/ingydotnet/git-subrepo.png" alt="git-subrepo"></a>
Bad:
=over
=item * --Subrepo is very new.-- (no longer true)
=item * --Not well tested in the wild.-- (no longer true)
=back
This review may seem somewhat slanted, but I honestly am not aware of any
"bad" points that I'm not disclosing. That said, I am sure time will reveal
bugs and shortcomings. Those can usually be fixed. Hopefully the B<model> is
correct, because that's harder to fix down the road.
OK. So how does it all work?
There are 3 main commands: cloneI<pull>push. Let's start with the clone
command. This is the easiest part. You give it a remote url, possibly a new
subdir to put it, and possibly a remote branch to use. I say possibly, because
the command can guess the subdir name (just like the git-clone command does),
and the branch can be the upstream default branch.
Given this we do the following steps internally:
=over
=item * Fetch the remote content (for a specific refspec)
=item * Read the remote head tree into the index
=item * Checkout the index into the new subdir
=item * Create a new subrepo commit object for the subdir content
=item * Add a state file called .gitrepo to the new subrepo/subdir
=item * Amend the merge commit with this new file
=back
This process adds something like this to the top of your history:
* 9b6ddc9 git subrepo clone git@github.com:you/foo.git foo/
* 37c61a5 Previous head commit of your repo
The entire history has been squashed down into one commit, and placed on
top of your history. This is important as it keeps your history as clean
as possible. You don't need to have the subrepo history in your main
project, since it is immutably available elsewhere, and you have a pointer
to that place.
The new foo/.gitrepo file looks like this:
[subrepo]
remote = git@github.com:you/foo.git
branch = master
commit = 14c96c6931b41257b2d42b2edc67ddc659325823
parent = 37c61a5a234f5dd6f5c2aec037509f50d3a79b8f
cmdver = 0.1.0
It contains all the info needed now and later. Note that the repo url is the
generally pushable form, rather than the publically readable (L<https://…)>
form. This is the best practice. Users of your repo don't need access to this
url, because the content is already in your repo. Only you and your
collaborators need this url to pull/push in the future.
The next command is the pull command. Normally you just give it the subrepo's
subdir path (although you can change the branch with -b), and it will get the
other info from the subdir/.gitrepo file.
The pull command does these steps:
=over
=item * Fetch the upstream content
=item * Check if anything needs pulling
=item * Create a branch of local subrepo commits since last pull
=item * Rebase this branch onto the upstream commits
=item * Commit the HEAD of the rebased content
=item * Update/amend the .gitrepo file
=back
=head3 Clean History
I've talked a bit about clean history but let me show you a comparison between
subrepo and subtree. Let's run this command sequence using both methods. Note
the differences between I<both> the command syntax required, and the branch
history produced.
Subrepo first:
$ git subrepo clone git@github.com:user/abc
$ git subrepo clone git@github.com:user/def xyz
$ git subrepo pull abc
$ git subrepo pull xyz
The resulting history is:
* b1f60cc subrepo pull xyz
* 4fb0276 subrepo pull abc
* bcef2a0 subrepo clone git@github.com:user/def xyz
* bebf0db subrepo clone git@github.com:user/abc
* 64eeaa6 (origin/master, origin/HEAD) O HAI FREND
Compare that to B<subtree>. This:
$ git subtree add abc git@github.com:user/abc master
$ git subtree add xyz git@github.com:user/def master
$ git subtree pull abc git@github.com:user/abc master
$ git subtree pull xyz git@github.com:user/def master
Produces this:
* 739e45a (HEAD, master) Merge commit '5f563469d886d53e19cb908b3a64e4229f88a2d1'
|\
| * 5f56346 Squashed 'xyz/' changes from 08c7421..365409f
* | 641f5e5 Merge commit '8d88e90ce5f653ed2e7608a71b8693a2174ea62a'
|\ \
| * | 8d88e90 Squashed 'abc/' changes from 08c7421..365409f
* | | 1703ed2 Merge commit '0e091b672c4bbbbf6bc4f6694c475d127ffa21eb' as 'xyz'
|\ \ \
| | |/
| |/|
| * | 0e091b6 Squashed 'xyz/' content from commit 08c7421
| /
* | 07b77e7 Merge commit 'cd2b30a0229d931979ed4436b995875ec563faea' as 'abc'
|\ \
| |/
| * cd2b30a Squashed 'abc/' content from commit 08c7421
* 64eeaa6 (origin/master, origin/HEAD) O HAI FREND
This was from a minimal case. Subtree history (when viewed this way at least)
gets unreasonably ugly fast. Subrepo history, by contrast, always looks as
clean as shown.
The final command, push, bascially just does the pull/rebase dance above
described, and pushes the resulting history back. It does not squash the
commits made locally, because it assumed that when you changed the local
subrepo, you made messages that were intended to eventually be published
back upstream.
=head2 Conflict Resolution
The commands described above can also be done "by hand". If something fails
during a pull or push (generally in the rebasing) then the command will tell
you what to do to finish up.
You might choose to do everything by hand, and do your own merging strategies.
This is perfectly reasonable. The C<subrepo> command offers a few other helper
commands to help you get the job done:
=over
=item * C<fetch> - Fetch the upstream and create a C<< subrepo/remote/<subdir> >> ref.
=item * C<branch> - Create a branch of local subdir commits since the last pull, called C<< subrepo/<subdir> >>.
=item * C<commit> - Commit a merged branch's HEAD back into your repo.
=item * C<status> - Show lots of useful info about the current state of the subrepos.
=item * C<clean> - Remove branches, ref and remotes created by subrepo commands.
=item * C<help> - Read the complete documentation!
=back
=head2 Conclusion
Hopefully by now, you see that submodules are a painful choice with a dubious
future, and that subtree, while a solid idea has many usage issues.
Give C<subrepo> a try. It's painless, easily revertable and just might be what
the doctor ordered.
=head2 Reference Links
=over
=item * L<http://longair.net/blog/2010/06/02/git-submodules-explained/>
=item * L<http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/>
=back
=cut

21
build/git-subrepo/License Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-2020 Ingy döt Net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,82 @@
# Make sure we have 'git' and it works OK:
ifeq ($(shell which git),)
$(error 'git' is not installed on this system)
endif
# Set variables:
NAME := git-subrepo
LIB := lib/$(NAME)
DOC := doc/$(NAME).swim
MAN1 := man/man1
EXT := $(LIB).d
EXTS := $(shell find $(EXT) -type f) \
$(shell find $(EXT) -type l)
SHARE = share
# Install variables:
PREFIX ?= /usr/local
INSTALL_LIB ?= $(DESTDIR)$(shell git --exec-path)
INSTALL_EXT ?= $(INSTALL_LIB)/$(NAME).d
INSTALL_MAN1 ?= $(DESTDIR)$(PREFIX)/share/man/man1
# Basic targets:
default: help
help:
@echo 'Makefile rules:'
@echo ''
@echo 'test Run all tests'
@echo 'install Install $(NAME)'
@echo 'uninstall Uninstall $(NAME)'
@echo 'env Show environment variables to set'
.PHONY: test
test:
prove $(PROVEOPT:%=% )test/
# Install support:
install:
install -d -m 0755 $(INSTALL_LIB)/
install -C -m 0755 $(LIB) $(INSTALL_LIB)/
install -d -m 0755 $(INSTALL_EXT)/
install -C -m 0755 $(EXTS) $(INSTALL_EXT)/
install -d -m 0755 $(INSTALL_MAN1)/
install -C -m 0644 $(MAN1)/$(NAME).1 $(INSTALL_MAN1)/
# Uninstall support:
uninstall:
rm -f $(INSTALL_LIB)/$(NAME)
rm -fr $(INSTALL_EXT)
rm -f $(INSTALL_MAN1)/$(NAME).1
env:
@echo "export PATH=\"$$PWD/lib:\$$PATH\""
@echo "export MANPATH=\"$$PWD/man:\$$MANPATH\""
# Doc rules:
.PHONY: doc
update: doc compgen
force:
doc: ReadMe.pod Intro.pod $(MAN1)/$(NAME).1
perl pkg/bin/generate-help-functions.pl $(DOC) > \
$(EXT)/help-functions.bash
ReadMe.pod: $(DOC) force
swim --to=pod --wrap --complete $< > $@
Intro.pod: doc/intro-to-subrepo.swim force
swim --to=pod --wrap --complete $< > $@
$(MAN1)/%.1: doc/%.swim Makefile force
swim --to=man --wrap $< > $@
compgen: force
perl pkg/bin/generate-completion.pl bash $(DOC) $(LIB) > \
$(SHARE)/completion.bash
perl pkg/bin/generate-completion.pl zsh $(DOC) $(LIB) > \
$(SHARE)/zsh-completion/_git-subrepo
clean purge:
rm -fr tmp

28
build/git-subrepo/Meta Normal file
View file

@ -0,0 +1,28 @@
=meta: 0.0.2
name: git-subrepo
version: 0.4.1
abstract: Git Submodule Alternative
homepage: https://github.com/ingydotnet/git-subrepo#readme
license: MIT
copyright: 2013-2020
author:
name: Ingy döt Net
email: ingy@ingy.net
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net
requires:
bash: 4.0.0
git: 2.7.0
test:
cmd: make test
install: make install
devel:
git: git@github.org:ingydotnet/git-subrepo.git
irc: irc.freenode.net/gitcommands
bug: https://github.com/ingydotnet/git-subrepo/issues/

View file

@ -0,0 +1,698 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.48.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Name
git-subrepo - Git Submodule Alternative
=for html
<a href="https://travis-ci.org/ingydotnet/git-subrepo"><img src="https://travis-ci.org/ingydotnet/git-subrepo.png" alt="git-subrepo"></a>
=head1 Synopsis
git subrepo -h # Help Overview
git subrepo clone <remote-url> [<subdir>]
git subrepo init <subdir>
git subrepo pull <subdir>
git subrepo push <subdir>
git subrepo fetch <subdir>
git subrepo branch <subdir>
git subrepo commit <subdir>
git subrepo config <subdir>
git subrepo status [<subdir>]
git subrepo clean <subdir>
git subrepo help [<command> | --all]
git subrepo version
git subrepo upgrade
=head1 Description
This git command "clones" an external git repo into a subdirectory of your
repo. Later on, upstream changes can be pulled in, and local changes can be
pushed back. Simple.
=head1 Benefits
This command is an improvement from C<git-submodule> and C<git-subtree>; two
other git commands with similar goals, but various problems.
It assumes there are 3 main roles of people interacting with a repo, and
attempts to serve them all well:
=over
=item * B<owner> - The person who authors/owns/maintains a repo.
=item * B<users> - People who are just using/installing the repo.
=item * B<collaborators> - People who commit code to the repo and subrepos.
=back
The C<git-subrepo> command benefits these roles in the following ways:
=over
=item * Simple and intuitive commandline usage (with tab completion).
=item * Users get your repo and all your subrepos just by cloning your repo.
=item * Users do not need to install C<git-subrepo>, ever.
=item * Collaborators do not need to install unless they want to push/pull.
=item * Collaborators know when a subdir is a subrepo (it has a C<.gitrepo> file).
=item * The C<.gitrepo> file never gets pushed back to the subrepo upstream.
=item * Well named branches and remotes are generated for manual operations.
=item * Owners do not deal with the complications of keeping submodules in sync.
=item * Subrepo repositories can contain subrepos themselves.
=item * Branching with subrepos JustWorks™.
=item * Different branches can have different subrepos in different states, etc.
=item * Moving/renaming/deleting a subrepo subdir JustWorks™.
=item * You can C<init> an existing subdirectory into a subrepo.
=item * Your git history is kept squeaky clean.
=item * Upstream history (clone/pull) is condensed into a single commit.
=item * Pulls can use a C<merge>, C<rebase> or C<force> strategies.
=item * You can see the subrepo history with C<< git log subrepo/<subdir>/fetch >>.
=item * Commits pushed back upstream are B<not> condensed (by default).
=item * Trivial to try any subrepo operations and then reset back.
=item * No configuration required.
=item * Does not introduce history that messes up other git commands.
=item * Fixes known rebase failures with C<git-subtree>.
=back
=head1 Installation
The best short answer is:
git clone https://github.com/ingydotnet/git-subrepo /path/to/git-subrepo
echo 'source /path/to/git-subrepo/.rc' >> ~/.bashrc
The complete "Installation Instructions" can be found below.
Note: git-subrepo needs a git version (> 2.7) that supports worktree:s.
=head1 Commands
All the B<subrepo> commands use names of actual Git commands and try to do
operations that are similar to their Git counterparts. They also attempt to
give similar output in an attempt to make the subrepo usage intuitive to
experienced Git users.
Please note that the commands are I<not> exact equivalents, and do not take
all the same arguments. Keep reading…
=over
=item C<< git subrepo clone <repository> [<subdir>] [-b <branch>] [-f] [-m <msg>] [-e] [--method <merge|rebase>] >>
Add a repository as a subrepo in a subdir of your repository.
This is similar in feel to C<git clone>. You just specify the remote repo url,
and optionally a sub-directory and/or branch name. The repo will be fetched
and merged into the subdir.
The subrepo history is I<squashed> into a single commit that contains the
reference information. This information is also stored in a special file
called C<< <subdir>/.gitrepo >>. The presence of this file indicates that the
directory is a subrepo.
All subsequent commands refer to the subrepo by the name of the
I<subdir>. From the subdir, all the current information about the subrepo
can be obtained.
The C<--force> option will "reclone" (completely replace) an existing subdir.
The C<--method> option will decide how the join process between branches are
performed. The default option is merge.
The C<clone> command accepts the C<--branch=> C<--edit>, C<--force> and C<--
message=> options.
=item C<< git subrepo init <subdir> [-r <remote>] [-b <branch>] [--method <merge|rebase>] >>
Turn an existing subdirectory into a subrepo.
If you want to expose a subdirectory of your project as a published subrepo,
this command will do that. It will split out the content of a normal
subdirectory into a branch and start tracking it as a subrepo. Afterwards your
original repo will look exactly the same except that there will be a C<<
<subdir>/.gitrepo >> file.
If you specify the C<--remote> (and optionally the C<--branch>) option, the
values will be added to the C<< <subdir>/.gitrepo >> file. The C<--remote>
option is the upstream URL, and the C<--branch> option is the upstream branch
to push to. These values will be needed to do a C<git subrepo push> command,
but they can be provided later on the C<push> command (and saved to C<<
<subdir>/.gitrepo >> if you also specify the C<--update> option).
Note: You will need to create the empty upstream repo and push to it on your
own, using C<< git subrepo push <subdir> >>.
The C<--method> option will decide how the join process between branches are
performed. The default option is merge.
The C<init> command accepts the C<--branch=> and C<--remote=> options.
=item C<< git subrepo pull <subdir>|--all [-M|-R|-f] [-m <msg>] [-e] [-b <branch>] [-r <remote>] [-u] >>
Update the subrepo subdir with the latest upstream changes.
The C<pull> command fetches the latest content from the remote branch pointed
to by the subrepo's C<.gitrepo> file, and then tries to merge the changes into
the corresponding subdir. It does this by making a branch of the local commits
to the subdir and then merging or rebasing (see below) it with the fetched
upstream content. After the merge, the content of the new branch replaces your
subdir, the C<.gitrepo> file is updated and a single 'pull' commit is added to
your mainline history.
The C<pull> command will attempt to do the following commands in one go:
git subrepo fetch <subdir>
git subrepo branch <subdir>
git merge/rebase subrepo/<subdir>/fetch subrepo/<subdir>
git subrepo commit <subdir>
# Only needed for a consequential push:
git update-ref refs/subrepo/<subdir>/pull subrepo/<subdir>
In other words, you could do all the above commands yourself, for the same
effect. If any of the commands fail, subrepo will stop and tell you to finish
this by hand. Generally a failure would be in the merge or rebase part, where
conflicts can happen. Since Git has lots of ways to resolve conflicts to your
personal tastes, the subrepo command defers to letting you do this by hand.
When pulling new data, the method selected in clone/init is used. This has no
effect on the final result of the pull, since it becomes a single commit. But
it does affect the resulting C<< subrepo/<subdir> >> branch, which is often
used for a subrepo C<push> command. See 'push' below for more information. If
you want to change the method you can use the C<config> command for this.
When you pull you can assume a fast-forward strategy (default) or you can
specify a C<--rebase>, C<--merge> or C<--force> strategy. The latter is the
same as a C<clone --force> operation, using the current remote and branch.
Like the C<clone> command, C<pull> will squash all the changes (since the last
pull or clone) into one commit. This keeps your mainline history nice and
clean. You can easily see the subrepo's history with the C<git log> command:
git log refs/subrepo/<subdir>/fetch
The set of commands used above are described in detail below.
The C<pull> command accepts the C<--all>, C<--branch=>, C<--edit>, C<--force>,
C<--message=>, C<--remote=> and C<--update> options.
=item C<< git subrepo push <subdir>|--all [<branch>] [-r <remote>] [-b <branch>] [-M|-R] [-u] [-f] [-s] [-N] >>
Push a properly merged subrepo branch back upstream.
This command takes the subrepo branch from a successful pull command and
pushes the history back to its designated remote and branch. You can also use
the C<branch> command and merge things yourself before pushing if you want to
(although that is probably a rare use case).
The C<push> command requires a branch that has been properly merged/rebased
with the upstream HEAD (unless the upstream HEAD is empty, which is common
when doing a first C<push> after an C<init>). That means the upstream HEAD is
one of the commits in the branch.
By default the branch ref C<< refs/subrepo/<subdir>/pull >> will be pushed,
but you can specify a (properly merged) branch to push.
After that, the C<push> command just checks that the branch contains the
upstream HEAD and then pushes it upstream.
The C<--force> option will do a force push. Force pushes are typically
discouraged. Only use this option if you fully understand it. (The C<--force>
option will NOT check for a proper merge. ANY branch will be force pushed!)
The C<push> command accepts the C<--all>, C<--branch=>, C<--dry-run>, C<--
force>, C<--merge>, C<--rebase>, C<--remote=>, C<--squash> and C<--
update> options.
=item C<< git subrepo fetch <subdir>|--all [-r <remote>] [-b <branch>] >>
Fetch the remote/upstream content for a subrepo.
It will create a Git reference called C<< subrepo/<subdir>/fetch >> that
points at the same commit as C<FETCH_HEAD>. It will also create a remote
called C<< subrepo/<subdir> >>. These are temporary and you can easily remove
them with the subrepo C<clean> command.
The C<fetch> command accepts the C<--all>, C<--branch=> and C<--
remote=> options.
=item C<< git subrepo branch <subdir>|--all [-f] [-F] >>
Create a branch with local subrepo commits.
Scan the history of the mainline for all the commits that affect the C<subdir>
and create a new branch from them called C<< subrepo/<subdir> >>.
This is useful for doing C<pull> and C<push> commands by hand.
Use the C<--force> option to write over an existing C<< subrepo/<subdir>
>> branch.
The C<branch> command accepts the C<--all>, C<--fetch> and C<--force> options.
=item C<< git subrepo commit <subdir> [<subrepo-ref>] [-m <msg>] [-e] [-f] [-F] >>
Add subrepo branch to current history as a single commit.
This command is generally used after a hand-merge. You have done a C<subrepo
branch> and merged (rebased) it with the upstream. This command takes the HEAD
of that branch, puts its content into the subrepo subdir and adds a new commit
for it to the top of your mainline history.
This command requires that the upstream HEAD be in the C<< subrepo/<subdir> >>
branch history. That way the same branch can push upstream. Use the C<--force>
option to commit anyway.
The C<commit> command accepts the C<--edit>, C<--fetch>, C<--force> and C<--
message=> options.
=item C<< git subrepo status [<subdir>|--all|--ALL] [-F] [-q|-v] >>
Get the status of a subrepo. Uses the C<--all> option by default. If the C<--
quiet> flag is used, just print the subrepo names, one per line.
The C<--verbose> option will show all the recent local and upstream commits.
Use C<--ALL> to show the subrepos of the subrepos (ie the
"subsubrepos"), if any.
The C<status> command accepts the C<--all>, C<--ALL>, C<--fetch>, C<--quiet>
and C<--verbose> options.
=item C<< git subrepo clean <subdir>|--all|--ALL [-f] >>
Remove artifacts created by C<fetch> and C<branch> commands.
The C<fetch> and C<branch> operations (and other commands that call them)
create temporary things like refs, branches and remotes. This command removes
all those things.
Use C<--force> to remove refs. Refs are not removed by default because they
are sometimes needed between commands.
Use C<--all> to clean up after all the current subrepos. Sometimes you might
change to a branch where a subrepo doesn't exist, and then C<--all> won't find
it. Use C<--ALL> to remove any artifacts that were ever created by subrepo.
To remove ALL subrepo artifacts:
git subrepo clean --ALL --force
The C<clean> command accepts the C<--all>, C<--ALL>, and C<--force> options.
=item C<< git subrepo config <subdir> <option> [<value>] [-f] >>
Read or update configuration values in the subdir/.gitrepo file.
Because most of the values stored in the .gitrepo file are generated you
will need to use C<--force> if you want to change anything else then the
C<method> option.
Example to update the C<method> option for a subrepo:
git subrepo config foo method rebase
=item C<< git subrepo help [<command>|--all] >>
Same as C<git help subrepo>. Will launch the manpage. For the shorter usage,
use C<git subrepo -h>.
Use C<< git subrepo help <command> >> to get help for a specific command. Use
C<--all> to get a summary of all commands.
The C<help> command accepts the C<--all> option.
=item C<git subrepo version [-q|-v]>
This command will display version information about git-subrepo and its
environment. For just the version number, use C<git subrepo --version>. Use
C<--verbose> for more version info, and C<--quiet> for less.
The C<version> command accepts the C<--quiet> and C<--verbose> options.
=item C<git subrepo upgrade>
Upgrade the C<git-subrepo> software itself. This simply does a C<git pull>
on the git repository that the code is running from. It only works if you
are on the C<master> branch. It won't work if you installed C<git-subrepo>
using C<make install>; in that case you'll need to C<make install> from the
latest code.
=back
=head1 Command Options
=over
=item C<-h>
Show a brief view of the commands and options.
=item C<--help>
Gives an overview of the help options available for the subrepo command.
=item C<--version>
Print the git-subrepo version. Just the version number. Try the C<version>
command for more version info.
=item C<--all> (C<-a>)
If you have multiple subrepos, issue the command to all of them (if
applicable).
=item C<--ALL> (C<-A>)
If you have subrepos that also have subrepos themselves, issue the command to
ALL of them. Note that the C<--ALL> option only works for a subset of the
commands that C<--all> works for.
=item C<< --branch=<branch-name> >> (C<< -b <branch-name> >>)
Use a different upstream branch-name than the remote HEAD or the one saved in
C<.gitrepo> locally.
=item C<--dry-run> (C<-N>)
For the push command, do everything up until the push and then print out the
actual C<git push> command needed to finish the operation.
=item C<--edit> (C<-e>)
Edit the commit message before committing.
=item C<--fetch> (C<-F>)
Use this option to fetch the upstream commits, before running the command.
=item C<--force> (C<-f>)
Use this option to force certain commands that fail in the general case.
NOTE: The C<--force> option means different things for different commands.
Read the command specific doc for the exact meaning.
=item C<--merge> (C<-M>)
Use a C<merge> strategy to include upstream subrepo commits on a pull (or
setup for push).
=item C<< --message=<message> >> (C<< -m <message> >>)
Specify your own commit message on the command line.
=item C<--rebase> (C<-R>)
Use a C<rebase> strategy to include upstream subrepo commits on a pull (or
setup for push).
=item C<< --remote=<remote-url> >> (C<< -r <remote-url> >>)
Use a different remote-url than the one saved in C<.gitrepo> locally.
=item C<--squash> (C<-s>)
Squash all commits on a push into one new commit.
=item C<--update> (C<-u>)
If C<--branch> or C<--remote> are used, and the command updates the
C<.gitrepo> file, include these values to the update.
=back
=head1 Output Options
=over
=item C<--quiet> (C<-q>)
Print as little info as possible. Applicable to most commands.
=item C<--verbose> (C<-v>)
Print more information about the command execution and results. Applicable to
most commands.
=item C<--debug> (C<-d>)
Show the actual git (and other) commands being executed under the hood.
Applicable to most commands.
=item C<--DEBUG> (C<-x>)
Use the Bash C<set -x> option which prints every command before it is
run. VERY noisy, but extremely useful in deep debugging. Applicable to
all commands.
=back
=head1 Environment Variables
The C<git-subrepo> command exports and honors some environment variables:
=over
=item C<GIT_SUBREPO_ROOT>
This is set by the C<.rc> file, if you use that method to install / enable C<git-
subrepo>. It contains the path of the C<git-subrepo> repository.
=item C<GIT_SUBREPO_RUNNING>
This variable is exported when C<git-subrepo> is running. It is set to the pid
of the C<git-subrepo> process that is running. Other processes, like git hooks
for instance, can use this information to adjust accordingly.
=item C<GIT_SUBREPO_COMMAND>
This variable is exported when C<git-subrepo> is running. It is set to the
name of the C<git-subrepo> subcommand that is running.
=item C<GIT_SUBREPO_PAGER>
Use this to specify the pager to use for long output commands. Defaults to
C<$PAGER> or C<less>.
=item C<GIT_SUBREPO_QUIET>
Set this for quiet (C<-q>) output.
=item C<GIT_SUBREPO_VERBOSE>
Set this for verbose (C<-v>) output.
=item C<GIT_SUBREPO_DEBUG>
Set this for debugging (C<-d>) output.
=back
=head1 Installation Instructions
There are currently 3 ways to install C<git-subrepo>. For all of them you need
to get the source code from GitHub:
git clone https://github.com/ingydotnet/git-subrepo /path/to/git-subrepo
The first installation method is preferred: C<source> the C<.rc> file. Just
add a line like this one to your shell startup script:
source /path/to/git-subrepo/.rc
That will modify your C<PATH> and C<MANPATH>, and also enable command
completion.
The second method is to do these things by hand. This might afford you more
control of your shell environment. Simply add the C<lib> and C<man>
directories to your C<PATH> and C<MANPATH>:
export GIT_SUBREPO_ROOT="/path/to/git-subrepo"
export PATH="/path/to/git-subrepo/lib:$PATH"
export MANPATH="/path/to/git-subrepo/man:$MANPATH"
See below for info on how to turn on Command Completion.
The third method is a standard system install, which puts C<git-subrepo> next
to your other git commands:
make install # Possibly with 'sudo'
This method does not account for upgrading and command completion yet.
=head2 Windows
This command is known to work in these Windows environments:
=over
=item * Git for Windows -- L<https://git-for-windows.github.io/>
=item * Babun -- L<http://babun.github.io/>
=item * Cygwin -- L<https://www.cygwin.com/>
=back
Let us know if there are others that it works (or doesn't work) in.
=head1 Testing
The C<git-subrepo> repository comes with a extensive test suite. You can
run it with:
make test
or if you don't have C<make> on your system:
prove -v test
=head1 Upgrading
If you used the C<.rc> or C<PATH> method of installation, just run this to
upgrade C<git-subrepo>:
git subrepo upgrade
Or (same thing):
cd /path/to/git-subrepo
git pull
If you used C<make install> method, then run this again (after C<git pull>):
make install # Possibly with 'sudo'
=head1 Command Completion
The C<git subrepo> command supports C<< <TAB> >>-based command completion. If
you don't use the C<.rc> script (see Installation, above), you'll need to
enable this manually to use it.
=head2 In Bash
If your Bash setup does not already provide command completion for Git, you'll
need to enable that first:
source <Git completion script>
On your system, the Git completion script might be found at any of the
following locations (or somewhere else that we don't know about):
=over
=item * C</etc/bash_completion.d/git>
=item * C</usr/share/bash-completion/git>
=item * C</usr/share/bash-completion/completions/git>
=item * C</opt/local/share/bash-completion/completions/git>
=item * C</usr/local/etc/bash_completion.d/git>
=item * C<~/.homebrew/etc/bash_completion.d/git>
=back
In case you can't find any of these, this repository contains a copy of the
Git completion script:
source /path/to/git-subrepo/share/git-completion.bash
Once Git completion is enabled (whether you needed to do that manually or
not), you can turn on C<git-subrepo> completion with a command like this:
source /path/to/git-subrepo/share/completion.bash
=head2 In zsh
In the Z shell (zsh), you can manually enable C<git-subrepo> completion by
adding the following line to your C<~/.zshrc>, B<before> the C<compinit>
function is called:
fpath=('/path/to/git-subrepo/share/zsh-completion' $fpath)
=head1 Status
The git-subrepo command has been in use for well over a year and seems to get
the job done. Development is still ongoing but mostly just for fixing bugs.
Trying subrepo out is simple and painless (this is not C<git submodule>).
Nothing is permanent (if you do not push to shared remotes). ie You can always
play around and reset back to the beginning without pain.
This command has a test suite (run C<make test>), but surely has many bugs. If
you have expertise with Git and subcommands, please review the code, and file
issues on anything that seems wrong.
If you want to chat about the C<git-subrepo> command, join C<#gitcommands> on
C<irc.freenode.net>.
=head1 Notes
=over
=item * Works on POSIX systems: Linux, BSD, OSX, etc.
=item * Works on various Windows environments. See "Windows" section above.
=item * The C<git-subrepo> repo itself has 2 subrepos under the C<ext/> subdirectory.
=item * Written in (very modern) Bash, with full test suite. Take a look.
=item * A C<.gitrepo> file never is in the top level dir (next to a C<.git/> dir).
=back
=head1 Authors
=over
=item * Ingy döt Net <ingy@ingy.net>
=item * Magnus Carlsson <grimmymail@gmail.com>
=back
=head1 License and Copyright
The MIT License (MIT)
Copyright (c) 2013-2020 Ingy döt Net
=cut

View file

@ -0,0 +1,35 @@
= Comparing `submodule` and `subrepo`
This document compares Git's `submodule` command to the new `subrepo` command,
with examples and discussion of all the common operations. I'll use the term
"External" to mean the general concept of an external repo that might be used
as a submodule or a subrepo.
= Overview
= Adding a new External
As an owner or collaborator, you have decided to add a new External to your
repo:
- Submodule :: `git submodule add git@github.com/user/external`
- Subtree :: `git subtree --squash --prefix=external git@github.com/user/external`
- Subrepo :: `git subrepo clone git@github.com/user/external`
/…to be completed…/
= Updating from a changed External
= Pushing External changes upstream
= Moving/Renaming an External
= Making an External on a branch
= Changing the tracking branch of an External
= Removing an External
= Migration from One to the Other

View file

@ -0,0 +1,608 @@
git-subrepo
===========
Git Submodule Alternative
<badge travis ingydotnet/git-subrepo>
= Synopsis
git subrepo -h # Help Overview
git subrepo clone <remote-url> [<subdir>]
git subrepo init <subdir>
git subrepo pull <subdir>
git subrepo push <subdir>
git subrepo fetch <subdir>
git subrepo branch <subdir>
git subrepo commit <subdir>
git subrepo config <subdir>
git subrepo status [<subdir>]
git subrepo clean <subdir>
git subrepo help [<command> | --all]
git subrepo version
git subrepo upgrade
= Description
This git command "clones" an external git repo into a subdirectory of your
repo. Later on, upstream changes can be pulled in, and local changes can be
pushed back. Simple.
= Benefits
This command is an improvement from `git-submodule` and `git-subtree`; two
other git commands with similar goals, but various problems.
It assumes there are 3 main roles of people interacting with a repo, and
attempts to serve them all well:
* *owner* - The person who authors\/owns\/maintains a repo.
* *users* - People who are just using/installing the repo.
* *collaborators* - People who commit code to the repo and subrepos.
The `git-subrepo` command benefits these roles in the following ways:
* Simple and intuitive commandline usage (with tab completion).
* Users get your repo and all your subrepos just by cloning your repo.
* Users do not need to install `git-subrepo`, ever.
* Collaborators do not need to install unless they want to push/pull.
* Collaborators know when a subdir is a subrepo (it has a `.gitrepo` file).
* The `.gitrepo` file never gets pushed back to the subrepo upstream.
* Well named branches and remotes are generated for manual operations.
* Owners do not deal with the complications of keeping submodules in sync.
* Subrepo repositories can contain subrepos themselves.
* Branching with subrepos JustWorks™.
* Different branches can have different subrepos in different states, etc.
* Moving\/renaming\/deleting a subrepo subdir JustWorks™.
* You can `init` an existing subdirectory into a subrepo.
* Your git history is kept squeaky clean.
* Upstream history (clone/pull) is condensed into a single commit.
* Pulls can use a `merge`, `rebase` or `force` strategies.
* You can see the subrepo history with `git log subrepo/<subdir>/fetch`.
* Commits pushed back upstream are *not* condensed (by default).
* Trivial to try any subrepo operations and then reset back.
* No configuration required.
* Does not introduce history that messes up other git commands.
* Fixes known rebase failures with `git-subtree`.
= Installation
The best short answer is:
git clone https://github.com/ingydotnet/git-subrepo /path/to/git-subrepo
echo 'source /path/to/git-subrepo/.rc' >> ~/.bashrc
The complete "Installation Instructions" can be found below.
Note: git-subrepo needs a git version (> 2.7) that supports worktree:s.
= Commands
All the *subrepo* commands use names of actual Git commands and try to do
operations that are similar to their Git counterparts. They also attempt to
give similar output in an attempt to make the subrepo usage intuitive to
experienced Git users.
Please note that the commands are /not/ exact equivalents, and do not take all
the same arguments. Keep reading…
- `git subrepo clone <repository> [<subdir>] [-b <branch>] [-f] [-m <msg>] [-e] [--method <merge|rebase>]`
Add a repository as a subrepo in a subdir of your repository.
This is similar in feel to `git clone`. You just specify the remote repo
url, and optionally a sub-directory and/or branch name. The repo will be
fetched and merged into the subdir.
The subrepo history is /squashed/ into a single commit that contains the
reference information. This information is also stored in a special file
called `<subdir>/.gitrepo`. The presence of this file indicates that the
directory is a subrepo.
All subsequent commands refer to the subrepo by the name of the /subdir/.
From the subdir, all the current information about the subrepo can be
obtained.
The `--force` option will "reclone" (completely replace) an existing subdir.
The `--method` option will decide how the join process between branches are
performed. The default option is merge.
The `clone` command accepts the `--branch=` `--edit`, `--force` and
`--message=` options.
- `git subrepo init <subdir> [-r <remote>] [-b <branch>] [--method <merge|rebase>]`
Turn an existing subdirectory into a subrepo.
If you want to expose a subdirectory of your project as a published subrepo,
this command will do that. It will split out the content of a normal
subdirectory into a branch and start tracking it as a subrepo. Afterwards
your original repo will look exactly the same except that there will be a
`<subdir>/.gitrepo` file.
If you specify the `--remote` (and optionally the `--branch`) option, the
values will be added to the `<subdir>/.gitrepo` file. The `--remote` option
is the upstream URL, and the `--branch` option is the upstream branch to push
to. These values will be needed to do a `git subrepo push` command, but they
can be provided later on the `push` command (and saved to `<subdir>/.gitrepo`
if you also specify the `--update` option).
Note: You will need to create the empty upstream repo and push to it on your
own, using `git subrepo push <subdir>`.
The `--method` option will decide how the join process between branches
are performed. The default option is merge.
The `init` command accepts the `--branch=` and `--remote=` options.
- `git subrepo pull <subdir>|--all [-M|-R|-f] [-m <msg>] [-e] [-b <branch>] [-r <remote>] [-u]`
Update the subrepo subdir with the latest upstream changes.
The `pull` command fetches the latest content from the remote branch pointed
to by the subrepo's `.gitrepo` file, and then tries to merge the changes into
the corresponding subdir. It does this by making a branch of the local
commits to the subdir and then merging or rebasing (see below) it with the
fetched upstream content. After the merge, the content of the new branch
replaces your subdir, the `.gitrepo` file is updated and a single 'pull'
commit is added to your mainline history.
The `pull` command will attempt to do the following commands in one go:
git subrepo fetch <subdir>
git subrepo branch <subdir>
git merge/rebase subrepo/<subdir>/fetch subrepo/<subdir>
git subrepo commit <subdir>
# Only needed for a consequential push:
git update-ref refs/subrepo/<subdir>/pull subrepo/<subdir>
In other words, you could do all the above commands yourself, for the same
effect. If any of the commands fail, subrepo will stop and tell you to finish
this by hand. Generally a failure would be in the merge or rebase part, where
conflicts can happen. Since Git has lots of ways to resolve conflicts to your
personal tastes, the subrepo command defers to letting you do this by hand.
When pulling new data, the method selected in clone/init is used. This has
no effect on the final result of the pull, since it becomes a single commit.
But it does affect the resulting `subrepo/<subdir>` branch, which is often
used for a subrepo `push` command. See 'push' below for more information.
If you want to change the method you can use the `config` command for this.
When you pull you can assume a fast-forward strategy (default) or you can
specify a `--rebase`, `--merge` or `--force` strategy. The latter is the same
as a `clone --force` operation, using the current remote and branch.
Like the `clone` command, `pull` will squash all the changes (since the last
pull or clone) into one commit. This keeps your mainline history nice and
clean. You can easily see the subrepo's history with the `git log` command:
git log refs/subrepo/<subdir>/fetch
The set of commands used above are described in detail below.
The `pull` command accepts the `--all`, `--branch=`, `--edit`, `--force`,
`--message=`, `--remote=` and `--update` options.
- `git subrepo push <subdir>|--all [<branch>] [-r <remote>] [-b <branch>] [-M|-R] [-u] [-f] [-s] [-N]`
Push a properly merged subrepo branch back upstream.
This command takes the subrepo branch from a successful pull command and
pushes the history back to its designated remote and branch. You can also use
the `branch` command and merge things yourself before pushing if you want to
(although that is probably a rare use case).
The `push` command requires a branch that has been properly merged/rebased
with the upstream HEAD (unless the upstream HEAD is empty, which is common
when doing a first `push` after an `init`). That means the upstream HEAD is
one of the commits in the branch.
By default the branch ref `refs/subrepo/<subdir>/pull` will be pushed, but
you can specify a (properly merged) branch to push.
After that, the `push` command just checks that the branch contains the
upstream HEAD and then pushes it upstream.
The `--force` option will do a force push. Force pushes are typically
discouraged. Only use this option if you fully understand it. (The `--force`
option will NOT check for a proper merge. ANY branch will be force pushed!)
The `push` command accepts the `--all`, `--branch=`, `--dry-run`, `--force`,
`--merge`, `--rebase`, `--remote=`, `--squash` and `--update` options.
- `git subrepo fetch <subdir>|--all [-r <remote>] [-b <branch>]`
Fetch the remote/upstream content for a subrepo.
It will create a Git reference called `subrepo/<subdir>/fetch` that points at
the same commit as `FETCH_HEAD`. It will also create a remote called
`subrepo/<subdir>`. These are temporary and you can easily remove them with
the subrepo `clean` command.
The `fetch` command accepts the `--all`, `--branch=` and `--remote=` options.
- `git subrepo branch <subdir>|--all [-f] [-F]`
Create a branch with local subrepo commits.
Scan the history of the mainline for all the commits that affect the `subdir`
and create a new branch from them called `subrepo/<subdir>`.
This is useful for doing `pull` and `push` commands by hand.
Use the `--force` option to write over an existing `subrepo/<subdir>` branch.
The `branch` command accepts the `--all`, `--fetch` and `--force` options.
- `git subrepo commit <subdir> [<subrepo-ref>] [-m <msg>] [-e] [-f] [-F]`
Add subrepo branch to current history as a single commit.
This command is generally used after a hand-merge. You have done a `subrepo
branch` and merged (rebased) it with the upstream. This command takes the
HEAD of that branch, puts its content into the subrepo subdir and adds a new
commit for it to the top of your mainline history.
This command requires that the upstream HEAD be in the `subrepo/<subdir>`
branch history. That way the same branch can push upstream. Use the
`--force` option to commit anyway.
The `commit` command accepts the `--edit`, `--fetch`, `--force` and
`--message=` options.
- `git subrepo status [<subdir>|--all|--ALL] [-F] [-q|-v]`
Get the status of a subrepo. Uses the `--all` option by default. If the
`--quiet` flag is used, just print the subrepo names, one per line.
The `--verbose` option will show all the recent local and upstream commits.
Use `--ALL` to show the subrepos of the subrepos (ie the "subsubrepos"), if
any.
The `status` command accepts the `--all`, `--ALL`, `--fetch`, `--quiet` and
`--verbose` options.
- `git subrepo clean <subdir>|--all|--ALL [-f]`
Remove artifacts created by `fetch` and `branch` commands.
The `fetch` and `branch` operations (and other commands that call them)
create temporary things like refs, branches and remotes. This command
removes all those things.
Use `--force` to remove refs. Refs are not removed by default because they
are sometimes needed between commands.
Use `--all` to clean up after all the current subrepos. Sometimes you might
change to a branch where a subrepo doesn't exist, and then `--all` won't find
it. Use `--ALL` to remove any artifacts that were ever created by subrepo.
To remove ALL subrepo artifacts:
git subrepo clean --ALL --force
The `clean` command accepts the `--all`, `--ALL`, and `--force` options.
- `git subrepo config <subdir> <option> [<value>] [-f]`
Read or update configuration values in the subdir/.gitrepo file.
Because most of the values stored in the .gitrepo file are generated you
will need to use `--force` if you want to change anything else then the
`method` option.
Example to update the `method` option for a subrepo:
git subrepo config foo method rebase
- `git subrepo help [<command>|--all]`
Same as `git help subrepo`. Will launch the manpage. For the shorter usage,
use `git subrepo -h`.
Use `git subrepo help <command>` to get help for a specific command. Use
`--all` to get a summary of all commands.
The `help` command accepts the `--all` option.
- `git subrepo version [-q|-v]`
This command will display version information about git-subrepo and its
environment. For just the version number, use `git subrepo --version`. Use
`--verbose` for more version info, and `--quiet` for less.
The `version` command accepts the `--quiet` and `--verbose` options.
- `git subrepo upgrade`
Upgrade the `git-subrepo` software itself. This simply does a `git pull` on
the git repository that the code is running from. It only works if you are on
the `master` branch. It won't work if you installed `git-subrepo` using `make
install`; in that case you'll need to `make install` from the latest code.
= Command Options
- `-h`
Show a brief view of the commands and options.
- `--help`
Gives an overview of the help options available for the subrepo command.
- `--version`
Print the git-subrepo version. Just the version number. Try the `version`
command for more version info.
- `--all` (`-a`)
If you have multiple subrepos, issue the command to all of them (if
applicable).
- `--ALL` (`-A`)
If you have subrepos that also have subrepos themselves, issue the command to
ALL of them. Note that the `--ALL` option only works for a subset of the
commands that `--all` works for.
- `--branch=<branch-name>` (`-b <branch-name>`)
Use a different upstream branch-name than the remote HEAD or the one saved in
`.gitrepo` locally.
- `--dry-run` (`-N`)
For the push command, do everything up until the push and then print out the
actual `git push` command needed to finish the operation.
- `--edit` (`-e`)
Edit the commit message before committing.
- `--fetch` (`-F`)
Use this option to fetch the upstream commits, before running the command.
- `--force` (`-f`)
Use this option to force certain commands that fail in the general case.
NOTE: The `--force` option means different things for different commands.
Read the command specific doc for the exact meaning.
- `--merge` (`-M`)
Use a `merge` strategy to include upstream subrepo commits on a pull (or
setup for push).
- `--message=<message>` (`-m <message>`)
Specify your own commit message on the command line.
- `--rebase` (`-R`)
Use a `rebase` strategy to include upstream subrepo commits on a pull (or
setup for push).
- `--remote=<remote-url>` (`-r <remote-url>`)
Use a different remote-url than the one saved in `.gitrepo` locally.
- `--squash` (`-s`)
Squash all commits on a push into one new commit.
- `--update` (`-u`)
If `--branch` or `--remote` are used, and the command updates the `.gitrepo`
file, include these values to the update.
= Output Options
- `--quiet` (`-q`)
Print as little info as possible. Applicable to most commands.
- `--verbose` (`-v`)
Print more information about the command execution and results. Applicable
to most commands.
- `--debug` (`-d`)
Show the actual git (and other) commands being executed under the hood.
Applicable to most commands.
- `--DEBUG` (`-x`)
Use the Bash `set -x` option which prints every command before it is run.
VERY noisy, but extremely useful in deep debugging. Applicable to all
commands.
= Environment Variables
The `git-subrepo` command exports and honors some environment variables:
- `GIT_SUBREPO_ROOT`
This is set by the `.rc` file, if you use that method to install / enable
`git-subrepo`. It contains the path of the `git-subrepo` repository.
- `GIT_SUBREPO_RUNNING`
This variable is exported when `git-subrepo` is running. It is set to the pid
of the `git-subrepo` process that is running. Other processes, like git hooks
for instance, can use this information to adjust accordingly.
- `GIT_SUBREPO_COMMAND`
This variable is exported when `git-subrepo` is running. It is set to the
name of the `git-subrepo` subcommand that is running.
- `GIT_SUBREPO_PAGER`
Use this to specify the pager to use for long output commands. Defaults to
`$PAGER` or `less`.
- `GIT_SUBREPO_QUIET`
Set this for quiet (`-q`) output.
- `GIT_SUBREPO_VERBOSE`
Set this for verbose (`-v`) output.
- `GIT_SUBREPO_DEBUG`
Set this for debugging (`-d`) output.
= Installation Instructions
There are currently 3 ways to install `git-subrepo`. For all of them you need
to get the source code from GitHub:
git clone https://github.com/ingydotnet/git-subrepo /path/to/git-subrepo
The first installation method is preferred: `source` the `.rc` file. Just add a
line like this one to your shell startup script:
source /path/to/git-subrepo/.rc
That will modify your `PATH` and `MANPATH`, and also enable command completion.
The second method is to do these things by hand. This might afford you more
control of your shell environment. Simply add the `lib` and `man` directories
to your `PATH` and `MANPATH`:
export GIT_SUBREPO_ROOT="/path/to/git-subrepo"
export PATH="/path/to/git-subrepo/lib:$PATH"
export MANPATH="/path/to/git-subrepo/man:$MANPATH"
See below for info on how to turn on Command Completion.
The third method is a standard system install, which puts `git-subrepo` next to
your other git commands:
make install # Possibly with 'sudo'
This method does not account for upgrading and command completion yet.
== Windows
This command is known to work in these Windows environments:
* Git for Windows -- https://git-for-windows.github.io/
* Babun -- http://babun.github.io/
* Cygwin -- https://www.cygwin.com/
Let us know if there are others that it works (or doesn't work) in.
= Testing
The `git-subrepo` repository comes with a extensive test suite. You can run it
with:
make test
or if you don't have `make` on your system:
prove -v test
= Upgrading
If you used the `.rc` or `PATH` method of installation, just run this to
upgrade `git-subrepo`:
git subrepo upgrade
Or (same thing):
cd /path/to/git-subrepo
git pull
If you used `make install` method, then run this again (after `git pull`):
make install # Possibly with 'sudo'
= Command Completion
The `git subrepo` command supports `<TAB>`-based command completion. If you
don't use the `.rc` script (see Installation, above), you'll need to enable
this manually to use it.
== In Bash
If your Bash setup does not already provide command completion for Git, you'll
need to enable that first:
source <Git completion script>
On your system, the Git completion script might be found at any of the
following locations (or somewhere else that we don't know about):
* `/etc/bash_completion.d/git`
* `/usr/share/bash-completion/git`
* `/usr/share/bash-completion/completions/git`
* `/opt/local/share/bash-completion/completions/git`
* `/usr/local/etc/bash_completion.d/git`
* `~/.homebrew/etc/bash_completion.d/git`
In case you can't find any of these, this repository contains a copy of the
Git completion script:
source /path/to/git-subrepo/share/git-completion.bash
Once Git completion is enabled (whether you needed to do that manually or
not), you can turn on `git-subrepo` completion with a command like this:
source /path/to/git-subrepo/share/completion.bash
== In zsh
In the Z shell (zsh), you can manually enable `git-subrepo` completion by
adding the following line to your `~/.zshrc`, *before* the `compinit` function
is called:
fpath=('/path/to/git-subrepo/share/zsh-completion' $fpath)
= Status
The git-subrepo command has been in use for well over a year and seems to get
the job done. Development is still ongoing but mostly just for fixing bugs.
Trying subrepo out is simple and painless (this is not `git submodule`).
Nothing is permanent (if you do not push to shared remotes). ie You can always
play around and reset back to the beginning without pain.
This command has a test suite (run `make test`), but surely has many bugs. If
you have expertise with Git and subcommands, please review the code, and file
issues on anything that seems wrong.
If you want to chat about the `git-subrepo` command, join `#gitcommands` on
`irc.freenode.net`.
= Notes
* Works on POSIX systems: Linux, BSD, OSX, etc.
* Works on various Windows environments. See "Windows" section above.
* The `git-subrepo` repo itself has 2 subrepos under the `ext/` subdirectory.
* Written in (very modern) Bash, with full test suite. Take a look.
* A `.gitrepo` file never is in the top level dir (next to a `.git/` dir).
= Authors
* Ingy döt Net <ingy@ingy.net>
* Magnus Carlsson <grimmymail@gmail.com>
= License and Copyright
The MIT License (MIT)
Copyright (c) 2013-2020 Ingy döt Net

View file

@ -0,0 +1,387 @@
= Introducing Git Subrepos
There is a new git command called `subrepo` that is meant to be a solid
alternative to the `submodule` and `subtree` commands. All 3 of these commands
allow you to include external repositories (pinned to specific commits) in
your main repository. This is an often needed feature for project development
under a source control system like Git. Unfortunately, the `submodule` command
is severely lacking, and the `subtree` command (an attempt to make things
better) is also very flawed. Fortunately, the `subrepo` command is here to
save the day.
This article will discuss how the previous commands work, and where they go
wrong, while explaining how the new `subrepo` command fixes the issues.
It should be noted that there are 3 distinct roles (ways people use repos)
involved in discussing this topic:
* *owner* — The primary author and repo owner
* *collaborators* — Other developers who contribute to the repo
* *users* — People who simply use the repo software
== Introducing `subrepo`
While the main point is to show how subrepo addresses the shortcomings of
submodule and subtree, I'll start by giving a quick intro to the subrepo
command.
Let's say that you have a project repo called 'freebird' and you want to have
it include 2 other external repos, 'lynyrd' and 'skynyrd'. You would do the
following:
git clone git@github.com/you/freebird
cd freebird
git subrepo clone git@github.com/you/lynyrd ext/lynyrd
git subrepo clone git@github.com/you/skynyrd ext/skynyrd --branch=1975
What these commands do (at a high level) should be obvious. They "clone"
(add) the repos content into the subdirectories you told them to. The details
of what is happening to your repo will be discussed later, but adding new
subrepos is easy. If you need to update the subrepos later:
git subrepo pull ext/lynyrd
git subrepo pull ext/skynyrd --branch=1976
The lynyrd repo is tracking the upstream master branch, and you've changed the
skynyrd subrepo to the 1976 branch. Since these subrepos are owned by 'you',
you might want to change them in the context of your freebird repo. When
things are working, you can push the subrepo changes back:
git subrepo push ext/lynyrd
git subrepo push ext/skynyrd
Looks simple right? It's supposed to be. The intent of `subrepo` is to do the
right things, and to not cause problems.
Of course there's more to it under the hood, and that's what the rest of this
article is about.
== Git Submodules
Submodules tend to receive a lot of bad press. Here's some of it:
* http://ayende.com/blog/4746/the-problem-with-git-submodules
* http://somethingsinistral.net/blog/git-submodules-are-probably-not-the-answer/
* http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/
A quick recap of some of the good and bad things about submodules:
Good:
* Use an external repo in a dedicated subdir of your project.
* Pin the external repo to a specific commit.
* The `git-submodule` command is a core part of the Git project.
Bad:
* Users have to know a repo has submodules.
* Users have to get the subrepos manually.
* Pulling a repo with submodules won't pull in the new submodule changes.
* A submodule will break if the referenced repo goes away.
* A submodule will break if a forced push removes the referenced commit.
* Can't use different submodules/commits per main project branch.
* Can't "try out" a submodule on alternate branch.
* Main repo can be pushed upstream pointing to unpushed submod commits.
* Command capability differs across Git versions.
* Often need to change remote url, to push submodule changes upstream.
* Removing or renaming a submodule requires many steps.
Internally, submodules are a real mess. They give the strong impression of
being bolted on, well after Git was designed. Some commands are aware of the
existence of submodules (although usually half-heartedly), and many commands
are oblivious. For instance the git-clone command has a `--recursive` option
to clone all subrepos, but it's not a default, so you still need to be aware
of the need. The git-checkout command does nothing with the submodules, even
if they are intended to differ across branches.
Let's talk a bit about how submodules are implemented in Git. Information
about them is stored in 3 different places (in the top level repo directory):
* `.gitmodules`
* `.git/config`
* `.git/modules` — The submodule repo's meta data (refs/objects)
So some of the information lives in the repo history (.gitmodules), but other
info (.git/) is only known to the local repo.
In addition, the submodule introduces a new low level concept, to the
commit/tree/blob graph. Normally a git tree object points to blob (file)
objects and more tree (directory) objects. Submodules have tree objects point
to *commit* objects. While this seems clever and somewhat reasonable, it also
means that every other git command (which was built on the super clean Git
data model) has to be aware of this new possibility (and deal with it
appropriately).
The point is that, while submodules are a real need, and a lot of work has
gone into making them work decently, they are essentially a kludge to the Git
model, and it is quite understandable why they haven't worked out as well as
people would expect.
NOTE: Submodules /are/ getting better with each release of Git, but it's still
an endless catch up game.
== Git Subtrees
One day, someone decided to think different. Instead of pointing to external
repos, why not just include them into the main repo (but also allow them to be
pulled and pushed separately as needed)?
At first this may feel like a wasteful approach. Why keep other repos
physically inside your main one? But if you think about it abstractly, what's
the difference? You want your users and collaborators to have all this code
because your project needs it. So why worry about how it happens? In the end,
the choice is yours, but I've grown very comfortable with this concept and
I'll try to justify it well. I should note that the first paragraph of the
`submodule` doc suggests considering this alternative.
The big win here is that you can do this using the existing git model.
Nothing new is added. You are just adding commits to a history. You can do it
different on every branch. You can merge branches sensibly.
The git-subtree command seems to have been inspired by Git's subtree merge
strategy, which it uses internally, and possibly got its name from. A subtree
merge allows you to take a completely separate Git history and make it be a
subdirectory of your repo.
Adding a subtree was the easy part. All that needed to be done after that was
to figure out a way to pull upstream changes and push local ones back
upstream. And that's what the `git-subtree` command does.
So what's the problem with git-subtree then?
Well unfortunately, it drops a few balls. The main problems come down to an
overly complicated commandline UX, poor collaborator awareness, and a fragile
and messy implementation.
Good:
* Use an external repo in a dedicated subdir of your project.
* Pin the external repo to a specific commit.
* Users get everything with a normal clone command.
* Users don't need to know that subtrees are involved.
* Can use different submodules/commits per main project branch.
* Users don't need the subtree command. Only owners and collaborators.
Bad:
* The remote url and branch info is not saved (except in the history).
* Owners and collaborators have to enter the remote for every command.
* Collaborators aren't made aware that subtrees are involved.
* Pulled history is not squashed by default.
* Creates a messy historical view. (See below)
* Bash code is complicated.
* Only one test file. Currently is failing.
As you can see, subtree makes quite a few things better, but after trying it
for a while, the experience was more annoying than submodules. For example,
consider this usage:
$ git subtree add --squash --prefix=foo git@github.com:my/thing mybranch
# weeks go by…
$ git subtree pull --squash --prefix=foo git@github.com:my/thing mybranch
# time to push local subtree changes back upstream
$ git subtree push --prefix=foo git@github.com:my/thing mybranch
The first thing you notice is the overly verbose syntax. It's justified in the
first command, but in the other 2 commands I really don't want to have to
remember what the remote and branch are that I'm using.
Moreover, my collaborators have no idea that subtrees are involved, let alone
where they came from.
Consider the equivalent subrepo commands:
$ git subrepo clone git@github.com:my/thing foo -b mybranch
$ git subrepo pull foo
$ git subrepo push foo
Collaborators see a file called 'foo/.gitrepo', and know that the subdir is a
subrepo. The file contains all the information needed by future commands
applied to that subrepo.
== Git Subrepos
Now is a good time to dive into the techinical aspects of the `subrepo`
command, but first let me explain how it came about.
As you may have surmised by now, I am the author of git-subrepo. I'd used
submodules on and off for years, and when I became aware of subtree I gave it
a try, but I quickly realized its problems. I decided maybe it could be
improved. I decided to write down my expected commandline usage and my ideals
of what it would and would not do. Then I set off to implement it. It's been a
long road, but what I ended up with was even better than what I wanted from
the start.
Let's review the Goods and Bads:
Good:
* Use an external repo in a dedicated subdir of your project.
* Pin the external repo to a specific commit.
* Users get everything with a normal clone command.
* Users don't need to know that subrepos are involved.
* Can use different submodules/commits per main project branch.
* Meta info is kept in an obvious place.
* Everyone knows when a subdir is a subrepo.
* Commandline UX is minimal and intuitive.
* Pulled history is always squashed out locally.
* Pushed history is kept intact.
* Creates a clean historical view. (See below)
* Bash code is very simple and easy to follow.
* Comprehensive test suite. Currently passing on travis:
<badge travis ingydotnet/git-subrepo>
Bad:
* --Subrepo is very new.-- (no longer true)
* --Not well tested in the wild.-- (no longer true)
This review may seem somewhat slanted, but I honestly am not aware of any
"bad" points that I'm not disclosing. That said, I am sure time will reveal
bugs and shortcomings. Those can usually be fixed. Hopefully the *model* is
correct, because that's harder to fix down the road.
OK. So how does it all work?
There are 3 main commands: clone/pull/push. Let's start with the clone
command. This is the easiest part. You give it a remote url, possibly a new
subdir to put it, and possibly a remote branch to use. I say possibly, because
the command can guess the subdir name (just like the git-clone command does),
and the branch can be the upstream default branch.
Given this we do the following steps internally:
* Fetch the remote content (for a specific refspec)
* Read the remote head tree into the index
* Checkout the index into the new subdir
* Create a new subrepo commit object for the subdir content
* Add a state file called .gitrepo to the new subrepo/subdir
* Amend the merge commit with this new file
This process adds something like this to the top of your history:
* 9b6ddc9 git subrepo clone git@github.com:you/foo.git foo/
* 37c61a5 Previous head commit of your repo
The entire history has been squashed down into one commit, and placed on top of
your history. This is important as it keeps your history as clean as possible.
You don't need to have the subrepo history in your main project, since it is
immutably available elsewhere, and you have a pointer to that place.
The new foo/.gitrepo file looks like this:
[subrepo]
remote = git@github.com:you/foo.git
branch = master
commit = 14c96c6931b41257b2d42b2edc67ddc659325823
parent = 37c61a5a234f5dd6f5c2aec037509f50d3a79b8f
cmdver = 0.1.0
It contains all the info needed now and later. Note that the repo url is the
generally pushable form, rather than the publically readable (https://…) form.
This is the best practice. Users of your repo don't need access to this url,
because the content is already in your repo. Only you and your collaborators
need this url to pull/push in the future.
The next command is the pull command. Normally you just give it the subrepo's
subdir path (although you can change the branch with -b), and it will get the
other info from the subdir/.gitrepo file.
The pull command does these steps:
* Fetch the upstream content
* Check if anything needs pulling
* Create a branch of local subrepo commits since last pull
* Rebase this branch onto the upstream commits
* Commit the HEAD of the rebased content
* Update/amend the .gitrepo file
=== Clean History
I've talked a bit about clean history but let me show you a comparison between
subrepo and subtree. Let's run this command sequence using both methods. Note
the differences between /both/ the command syntax required, and the branch
history produced.
Subrepo first:
$ git subrepo clone git@github.com:user/abc
$ git subrepo clone git@github.com:user/def xyz
$ git subrepo pull abc
$ git subrepo pull xyz
The resulting history is:
* b1f60cc subrepo pull xyz
* 4fb0276 subrepo pull abc
* bcef2a0 subrepo clone git@github.com:user/def xyz
* bebf0db subrepo clone git@github.com:user/abc
* 64eeaa6 (origin/master, origin/HEAD) O HAI FREND
Compare that to *subtree*. This:
$ git subtree add abc git@github.com:user/abc master
$ git subtree add xyz git@github.com:user/def master
$ git subtree pull abc git@github.com:user/abc master
$ git subtree pull xyz git@github.com:user/def master
Produces this:
* 739e45a (HEAD, master) Merge commit '5f563469d886d53e19cb908b3a64e4229f88a2d1'
|\
| * 5f56346 Squashed 'xyz/' changes from 08c7421..365409f
* | 641f5e5 Merge commit '8d88e90ce5f653ed2e7608a71b8693a2174ea62a'
|\ \
| * | 8d88e90 Squashed 'abc/' changes from 08c7421..365409f
* | | 1703ed2 Merge commit '0e091b672c4bbbbf6bc4f6694c475d127ffa21eb' as 'xyz'
|\ \ \
| | |/
| |/|
| * | 0e091b6 Squashed 'xyz/' content from commit 08c7421
| /
* | 07b77e7 Merge commit 'cd2b30a0229d931979ed4436b995875ec563faea' as 'abc'
|\ \
| |/
| * cd2b30a Squashed 'abc/' content from commit 08c7421
* 64eeaa6 (origin/master, origin/HEAD) O HAI FREND
This was from a minimal case. Subtree history (when viewed this way at least)
gets unreasonably ugly fast. Subrepo history, by contrast, always looks as
clean as shown.
The final command, push, bascially just does the pull/rebase dance above
described, and pushes the resulting history back. It does not squash the
commits made locally, because it assumed that when you changed the local
subrepo, you made messages that were intended to eventually be published back
upstream.
== Conflict Resolution
The commands described above can also be done "by hand". If something fails
during a pull or push (generally in the rebasing) then the command will tell
you what to do to finish up.
You might choose to do everything by hand, and do your own merging strategies.
This is perfectly reasonable. The `subrepo` command offers a few other helper
commands to help you get the job done:
* `fetch` - Fetch the upstream and create a `subrepo/remote/<subdir>` ref.
* `branch` - Create a branch of local subdir commits since the last pull,
called `subrepo/<subdir>`.
* `commit` - Commit a merged branch's HEAD back into your repo.
* `status` - Show lots of useful info about the current state of the subrepos.
* `clean` - Remove branches, ref and remotes created by subrepo commands.
* `help` - Read the complete documentation!
== Conclusion
Hopefully by now, you see that submodules are a painful choice with a dubious
future, and that subtree, while a solid idea has many usage issues.
Give `subrepo` a try. It's painless, easily revertable and just might be what
the doctor ordered.
== Reference Links
* http://longair.net/blog/2010/06/02/git-submodules-explained/
* http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/

View file

@ -0,0 +1,11 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = git@github.com:ingydotnet/bashplus.git
branch = master
commit = d9183af6f46946fabdef1dd8f37824c042a378f8
parent = 9b8f13e94677b2680a33ad204bebadcdb1ff9081
cmdver = 0.3.0

View file

@ -0,0 +1,6 @@
# C language gives closest shell env.
language: c
script:
- git submodule update --init --recursive
- PROVEOPT=-v make test

View file

@ -0,0 +1,15 @@
---
version: 0.0.7
date: Sat Jan 23 16:28:59 PST 2016
changes:
- Update tooling, and copyright
---
version: 0.0.6
date: Fri Jan 23 21:05:15 PST 2015
changes:
- Update tooling, and copyright
---
version: 0.0.1
date: Sun Oct 27 19:07:51 PDT 2013
changes:
- First release.

View file

@ -0,0 +1,21 @@
(The MIT License)
Copyright © 2013-2016 Ingy döt Net
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the Software), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,45 @@
ifeq ($(MAKECMDGOALS),install)
ifeq "$(shell bpan version 2>/dev/null)" ""
$(error 'BPAN not installed. See http://bpan.org')
endif
endif
NAME := bash+
LIB := lib/$(NAME).bash
DOC := doc/$(NAME).swim
MAN1 := man/man1
MAN3 := man/man3
INSTALL_LIB ?= $(shell bpan env BPAN_LIB)
INSTALL_DIR ?= test
INSTALL_MAN1 ?= $(shell bpan env BPAN_MAN1)
INSTALL_MAN3 ?= $(shell bpan env BPAN_MAN3)
default: help
help:
@echo 'Rules: test, install, doc'
.PHONY: test
test:
prove $(PROVEOPT:%=% )test/
install:
install -C -d -m 0755 $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -m 0755 $(LIB) $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -d -m 0755 $(INSTALL_MAN1)/
install -C -d -m 0755 $(INSTALL_MAN3)/
install -C -m 0644 $(MAN1)/$(NAME).1 $(INSTALL_MAN1)/
install -C -m 0644 $(MAN3)/$(NAME).3 $(INSTALL_MAN3)/
.PHONY: doc
doc: ReadMe.pod $(MAN1)/$(NAME).1 $(MAN3)/$(NAME).3
ReadMe.pod: $(DOC)
swim --to=pod --complete --wrap $< > $@
$(MAN1)/%.1: doc/%.swim
swim --to=man $< > $@
$(MAN3)/%.3: doc/%.swim
swim --to=man $< > $@

View file

@ -0,0 +1,28 @@
=meta: 0.0.2
name: bashplus
version: 0.0.7
abstract: Modern Bash Programming
homepage: http://bpan.org/package/bashplus/
license: MIT
copyright: 2013-2016
author:
name: Ingy döt Net
email: ingy@ingy.net
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net
requires:
bash: 3.2.0
test:
cmd: make test
install:
cmd: make install
devel:
git: git@github.org/ingydotnet/bashplus
irc: irc.freenode.net/bpan
bug: https://github.com/ingydotnet/bashplus/issues/

View file

@ -0,0 +1,77 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.41.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Name
Bash+(1) - Modern Bash Programming
=for html
<a href="https://travis-ci.org/ingydotnet/bashplus"><img src="https://travis-ci.org/ingydotnet/bashplus.png" alt="bashplus"></a>
=head1 Synopsis
source bash+ :std :array
use Foo::Bar this that
Array.new args "$@"
if args.empty?; then
die "I need args!"
fi
Foo::Bar.new foo args
this is awesome # <= this is a real command! (You just imported it)
=head1 Description
Bash+ is just Bash... B<plus> some libraries that can make Bash programming a
lot nicer.
=for comment # Installation
Get the source code from GitHub:
git clone git@github.com:ingydotnet/bashplus
Then run:
make test
make install # Possibly with 'sudo'
=head1 Usage
For now look at some libraries the use Bash+:
=over
=item * L<https://github.com/ingydotnet/git-hub>
=item * L<https://github.com/ingydotnet/json-bash>
=item * L<https://github.com/ingydotnet/test-more-bash>
=back
=head1 Status
If you are interested in chatting about this, C</join #bpan> on
irc.freenode.net.
=head1 Author
Written by Ingy döt Net <ingy@ingy.net>
=head1 Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).
=cut

View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# Bash+ - Modern Bash Programming
#
# Copyright (c) 2013-2016 Ingy döt Net
#------------------------------------------------------------------------------
set -e
shopt -s compat31&>/dev/null||:
#------------------------------------------------------------------------------
# Determine how `bash+` was called, and do the right thing:
#------------------------------------------------------------------------------
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
# 'bash+' is being sourced:
[[ "${BASH_SOURCE[0]}" =~ /bin/bash\\+$ ]] || {
echo "Invalid Bash+ path '${BASH_SOURCE[0]}'" 2> /dev/null
exit 1
}
source "${BASH_SOURCE[0]%/bin/*}"/lib/bash+.bash || return $?
bash+:import "$@"
return $?
else
if [ $# -eq 1 -a "$1" == --version ]; then
echo 'bash+ version 0.0.7'
else
cat <<...
Greetings modern Bash programmer. Welcome to Bash+!
Bash+ is framework that makes Bash programming more like Ruby and Perl.
See: https://github.com/bpan-org/bashplus
If you got here trying to use bash+ in a program, you need to source it:
source bash+
Happy Bash Hacking!
...
fi
fi

View file

@ -0,0 +1,61 @@
Bash+(1)
========
Modern Bash Programming
<badge travis ingydotnet/bashplus>
= Synopsis
source bash+ :std :array
use Foo::Bar this that
Array.new args "$@"
if args.empty?; then
die "I need args!"
fi
Foo::Bar.new foo args
this is awesome # <= this is a real command! (You just imported it)
= Description
Bash+ is just Bash... *plus* some libraries that can make Bash programming a
lot nicer.
## Installation
Get the source code from GitHub:
git clone git@github.com:ingydotnet/bashplus
Then run:
make test
make install # Possibly with 'sudo'
= Usage
For now look at some libraries the use Bash+:
* https://github.com/ingydotnet/git-hub
* https://github.com/ingydotnet/json-bash
* https://github.com/ingydotnet/test-more-bash
= Status
If you are interested in chatting about this, `/join #bpan` on
irc.freenode.net.
= Author
Written by Ingy döt Net <ingy@ingy.net>
= Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).

View file

@ -0,0 +1,134 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Bash+(1) 1"
.TH Bash+(1) 1 "January 2016" "Generated by Swim v0.1.41" "Modern Bash Programming"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "Name"
.IX Header "Name"
Bash+(1) \- Modern Bash Programming
.SH "Synopsis"
.IX Header "Synopsis"
.Vb 1
\& source bash+ :std :array
\&
\& use Foo::Bar this that
\&
\& Array.new args "$@"
\&
\& if args.empty?; then
\& die "I need args!"
\& fi
\&
\& Foo::Bar.new foo args
\&
\& this is awesome # <= this is a real command! (You just imported it)
.Ve
.SH "Description"
.IX Header "Description"
Bash+ is just Bash... \fBplus\fR some libraries that can make Bash programming a lot nicer.
.PP
Get the source code from GitHub:
.PP
.Vb 1
\& git clone git@github.com:ingydotnet/bashplus
.Ve
.PP
Then run:
.PP
.Vb 2
\& make test
\& make install # Possibly with \*(Aqsudo\*(Aq
.Ve
.SH "Usage"
.IX Header "Usage"
For now look at some libraries the use Bash+:
.IP "\(bu" 4
<https://github.com/ingydotnet/git\-hub>
.IP "\(bu" 4
<https://github.com/ingydotnet/json\-bash>
.IP "\(bu" 4
<https://github.com/ingydotnet/test\-more\-bash>
.SH "Status"
.IX Header "Status"
If you are interested in chatting about this, \f(CW\*(C`/join #bpan\*(C'\fR on irc.freenode.net.
.SH "Author"
.IX Header "Author"
Written by Ingy döt Net <ingy@ingy.net>
.SH "Copyright & License"
.IX Header "Copyright & License"
Copyright 2013\-2016. Ingy döt Net.
.PP
The \s-1MIT\s0 License (\s-1MIT\s0).

View file

@ -0,0 +1,134 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Bash+(1) 1"
.TH Bash+(1) 1 "January 2016" "Generated by Swim v0.1.41" "Modern Bash Programming"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "Name"
.IX Header "Name"
Bash+(1) \- Modern Bash Programming
.SH "Synopsis"
.IX Header "Synopsis"
.Vb 1
\& source bash+ :std :array
\&
\& use Foo::Bar this that
\&
\& Array.new args "$@"
\&
\& if args.empty?; then
\& die "I need args!"
\& fi
\&
\& Foo::Bar.new foo args
\&
\& this is awesome # <= this is a real command! (You just imported it)
.Ve
.SH "Description"
.IX Header "Description"
Bash+ is just Bash... \fBplus\fR some libraries that can make Bash programming a lot nicer.
.PP
Get the source code from GitHub:
.PP
.Vb 1
\& git clone git@github.com:ingydotnet/bashplus
.Ve
.PP
Then run:
.PP
.Vb 2
\& make test
\& make install # Possibly with \*(Aqsudo\*(Aq
.Ve
.SH "Usage"
.IX Header "Usage"
For now look at some libraries the use Bash+:
.IP "\(bu" 4
<https://github.com/ingydotnet/git\-hub>
.IP "\(bu" 4
<https://github.com/ingydotnet/json\-bash>
.IP "\(bu" 4
<https://github.com/ingydotnet/test\-more\-bash>
.SH "Status"
.IX Header "Status"
If you are interested in chatting about this, \f(CW\*(C`/join #bpan\*(C'\fR on irc.freenode.net.
.SH "Author"
.IX Header "Author"
Written by Ingy döt Net <ingy@ingy.net>
.SH "Copyright & License"
.IX Header "Copyright & License"
Copyright 2013\-2016. Ingy döt Net.
.PP
The \s-1MIT\s0 License (\s-1MIT\s0).

View file

@ -0,0 +1,12 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std
ok $? '`source bash+` works'
is "$BASHPLUS_VERSION" '0.0.7' 'BASHPLUS_VERSION is 0.0.7'
done_testing 2

View file

@ -0,0 +1,22 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+
foo() {
echo O HAI
}
like "$(type bar 2>&1)" 'bar: not found' \
'bar is not yet a function'
bash+:fcopy foo bar
type -t bar &>/dev/null
ok $? 'bar is now a function'
is "$(type foo | tail -n+3)" "$(type bar | tail -n+3)" \
'Copy matches original'
done_testing 3

View file

@ -0,0 +1,18 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std
ok "`bash+:can use`" 'use is imported'
ok "`bash+:can die`" 'die is imported'
ok "`bash+:can warn`" 'warn is imported'
ok "`! bash+:can import`" 'import is not imported'
ok "`! bash+:can main`" 'main is not imported'
ok "`! bash+:can fcopy`" 'fcopy is not imported'
ok "`! bash+:can findlib`" 'findlib is not imported'
ok "`! bash+:can can`" 'can is not imported'
done_testing 8

View file

@ -0,0 +1,23 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+
functions=(
use
import
fcopy
findlib
die
warn
can
)
for f in ${functions[@]}; do
is "$(type -t "bash+:$f")" function \
"bash+:$f is a function"
done
done_testing 7

View file

@ -0,0 +1,70 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# This is a tiny version of test-more-bash that I use here. test-more-bash uses
# bash+, so I want to avoid the circular dependency. This little guy does
# 80-90% what test-more-bash does, with minimal code. It's a good example of
# how nice Bash can be.
#------------------------------------------------------------------------------
plan() {
echo "1..$1"
}
pass() {
let run=run+1
echo "ok $run${1:+ - $1}"
}
fail() {
let run=run+1
echo "not ok $run${1:+ - $1}"
}
is() {
if [ "$1" == "$2" ]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Want: $2"
fi
}
ok() {
(exit ${1:-$?}) &&
pass "$2" ||
fail "$2"
}
like() {
if [[ "$1" =~ "$2" ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Like: $2"
fi
}
unlike() {
if [[ ! "$1" =~ "$2" ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Dont: $2"
fi
}
done_testing() {
echo "1..${1:-$run}"
}
diag() {
echo "# ${1//$'\n'/$'\n'# }" >&2
}
note() {
echo "# ${1//$'\n'/$'\n'# }"
}

View file

@ -0,0 +1,19 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std can
BASHLIB=test/lib
use Foo::Bar
ok $? 'use Foo::Bar - works'
ok "`can Foo::Bar:baz`" 'Function Foo::Bar:baz exists'
is "$Foo__Bar_VERSION" 1.2.3 '$Foo__Bar_VERSION == 1.2.3'
output=`use Foo::Foo Boo Booo`
ok $? 'use Foo::Foo Boo Booo - works'
is "$output" Boo---Booo 'Correct import called'
done_testing 5

View file

@ -0,0 +1,11 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = git@github.com:ingydotnet/test-more-bash.git
branch = master
commit = 24a6cceabff4d62a5fd25b8945bab6f618fb0b88
parent = 69e22c2e7f6aeadfecb8b00d57c976958da03733
cmdver = 0.3.0

View file

@ -0,0 +1,6 @@
# C language gives closest shell env.
language: c
script:
- git submodule update --init --recursive
- PROVEOPT=-v make test

View file

@ -0,0 +1,15 @@
---
version: 0.0.3
date: Sat Jan 23 16:39:20 PST 2016
changes:
- Make up to date
---
version: 0.0.2
date: Fri Jan 23 21:26:18 PST 2015
changes:
- Make up to date
---
version: 0.0.1
date: Sun Oct 27 22:53:10 PDT 2013
changes:
- First release.

View file

@ -0,0 +1,21 @@
(The MIT License)
Copyright © 2013-2016. Ingy döt Net.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the Software), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,20 @@
NAME := test-more
DOC := doc/$(NAME).swim
MAN3 := man/man3
default: help
help:
@echo 'Rules: test, doc'
.PHONY: test
test:
prove $(PROVEOPT:%=% )test/
doc: ReadMe.pod $(MAN3)/$(NAME).3
ReadMe.pod: $(DOC)
swim --to=pod --complete --wrap $< > $@
$(MAN3)/%.3: doc/%.swim
swim --to=man $< > $@

View file

@ -0,0 +1,30 @@
=meta: 0.0.2
name: test-more
version: 0.0.3
abstract: TAP Testing for Bash
homepage: http://bpan.org/package/test-more/
license: MIT
copyright: 2013-2016
author:
name: Ingy döt Net
email: ingy@ingy.net
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net
requires:
bash: 3.2.0
bashplus: 0.0.7
test-tap: 0.0.4
test:
cmd: make test
install:
cmd: make install
devel:
git: git@github.org/ingydotnet/test-more-bash.git
irc: irc.freenode.net#bpan
bug: https://github.com/ingydotnet/test-more-bash/issues/

View file

@ -0,0 +1,115 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.41.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Name
Test::More - TAP Testing for Bash
=for html
<a href="https://travis-ci.org/ingydotnet/test-more-bash"><img src="https://travis-ci.org/ingydotnet/test-more-bash.png" alt="test-more-bash"></a>
=head1 Synopsis
Write a test file like this. Maybe call it C<test/test.t>:
#!/usr/bin/env bash
TEST_MORE_PATH="/path/to/test-more-bash"
BASHLIB="`
find $TEST_MORE_PATH -type d |
grep -E '/(bin|lib)$' |
xargs -n1 printf "%s:"`"
PATH="$BASHLIB$PATH"
source bash+ :std
use Test::More
plan tests 8
some-command
ok $? 'some-command is ok'
# or:
ok "`some-command`" 'some-command is ok'
pass 'This will always pass'
fail 'This will always fail'
is `echo foo` 'foo' 'foo is foo'
isnt foo bar "foo isn't bar"
like food foo 'food is like foo'
unlike team I "There's no 'I' in 'team'"
diag "A message for stderr"
note "A message for stdout"
Run the test with C<prove> like this:
prove test/test.t
Prove knows it's Bash from the first line (the hashbang), and it just works.
=head1 Description
Test::More is the tried and true testing library for Perl. It uses TAP (the
Test Anything Protocol). This is the same thing for Bash. For the most part it
should work exactly the same.
=head1 Methods
This is the basic usage:
=over
=item * C<plan tests $count>
=item * C<ok $status_code "$label">
=item * C<pass "$label">
=item * C<fail "$label">
=item * C<is "$got" "$want" "label">
=item * C<isnt "$got" "$unwanted" "$label">
=item * C<like "$got" "$regex" "$label">
=item * C<unlike "$got" "$regex" "$label">
=item * C<diag "$message">
=item * C<note "$message">
=item * C<done_testing $count>
=item * C<plan skip_all "$reason">
=item * C<BAIL_OUT "$reason">
=back
More detailed info coming soon.
=head1 Author
Ingy döt Net <ingy@bpan.org>
=head1 Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT)
=cut

View file

@ -0,0 +1,89 @@
Test::More
==========
TAP Testing for Bash
<badge travis ingydotnet/test-more-bash>
= Synopsis
Write a test file like this. Maybe call it `test/test.t`:
#!/usr/bin/env bash
TEST_MORE_PATH="/path/to/test-more-bash"
BASHLIB="`
find $TEST_MORE_PATH -type d |
grep -E '/(bin|lib)$' |
xargs -n1 printf "%s:"`"
PATH="$BASHLIB$PATH"
source bash+ :std
use Test::More
plan tests 8
some-command
ok $? 'some-command is ok'
# or:
ok "`some-command`" 'some-command is ok'
pass 'This will always pass'
fail 'This will always fail'
is `echo foo` 'foo' 'foo is foo'
isnt foo bar "foo isn't bar"
like food foo 'food is like foo'
unlike team I "There's no 'I' in 'team'"
diag "A message for stderr"
note "A message for stdout"
Run the test with `prove` like this:
prove test/test.t
Prove knows it's Bash from the first line (the hashbang), and it just works.
= Description
Test::More is the tried and true testing library for Perl. It uses TAP (the
Test Anything Protocol). This is the same thing for Bash. For the most part it
should work exactly the same.
= Methods
This is the basic usage:
* `plan tests $count`
* `ok $status_code "$label"`
* `pass "$label"`
* `fail "$label"`
* `is "$got" "$want" "label"`
* `isnt "$got" "$unwanted" "$label"`
* `like "$got" "$regex" "$label"`
* `unlike "$got" "$regex" "$label"`
* `diag "$message"`
* `note "$message"`
* `done_testing $count`
* `plan skip_all "$reason"`
* `BAIL_OUT "$reason"`
More detailed info coming soon.
= Author
Ingy döt Net <ingy@bpan.org>
= Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT)

View file

@ -0,0 +1,11 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = git@github.com:ingydotnet/bashplus.git
branch = master
commit = d9183af6f46946fabdef1dd8f37824c042a378f8
parent = 05a1bddbe237bbf2c390048c80ca70d4f66c6a37
cmdver = 0.3.0

View file

@ -0,0 +1,6 @@
# C language gives closest shell env.
language: c
script:
- git submodule update --init --recursive
- PROVEOPT=-v make test

View file

@ -0,0 +1,15 @@
---
version: 0.0.7
date: Sat Jan 23 16:28:59 PST 2016
changes:
- Update tooling, and copyright
---
version: 0.0.6
date: Fri Jan 23 21:05:15 PST 2015
changes:
- Update tooling, and copyright
---
version: 0.0.1
date: Sun Oct 27 19:07:51 PDT 2013
changes:
- First release.

View file

@ -0,0 +1,21 @@
(The MIT License)
Copyright © 2013-2016 Ingy döt Net
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the Software), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,45 @@
ifeq ($(MAKECMDGOALS),install)
ifeq "$(shell bpan version 2>/dev/null)" ""
$(error 'BPAN not installed. See http://bpan.org')
endif
endif
NAME := bash+
LIB := lib/$(NAME).bash
DOC := doc/$(NAME).swim
MAN1 := man/man1
MAN3 := man/man3
INSTALL_LIB ?= $(shell bpan env BPAN_LIB)
INSTALL_DIR ?= test
INSTALL_MAN1 ?= $(shell bpan env BPAN_MAN1)
INSTALL_MAN3 ?= $(shell bpan env BPAN_MAN3)
default: help
help:
@echo 'Rules: test, install, doc'
.PHONY: test
test:
prove $(PROVEOPT:%=% )test/
install:
install -C -d -m 0755 $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -m 0755 $(LIB) $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -d -m 0755 $(INSTALL_MAN1)/
install -C -d -m 0755 $(INSTALL_MAN3)/
install -C -m 0644 $(MAN1)/$(NAME).1 $(INSTALL_MAN1)/
install -C -m 0644 $(MAN3)/$(NAME).3 $(INSTALL_MAN3)/
.PHONY: doc
doc: ReadMe.pod $(MAN1)/$(NAME).1 $(MAN3)/$(NAME).3
ReadMe.pod: $(DOC)
swim --to=pod --complete --wrap $< > $@
$(MAN1)/%.1: doc/%.swim
swim --to=man $< > $@
$(MAN3)/%.3: doc/%.swim
swim --to=man $< > $@

View file

@ -0,0 +1,28 @@
=meta: 0.0.2
name: bashplus
version: 0.0.7
abstract: Modern Bash Programming
homepage: http://bpan.org/package/bashplus/
license: MIT
copyright: 2013-2016
author:
name: Ingy döt Net
email: ingy@ingy.net
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net
requires:
bash: 3.2.0
test:
cmd: make test
install:
cmd: make install
devel:
git: git@github.org/ingydotnet/bashplus
irc: irc.freenode.net/bpan
bug: https://github.com/ingydotnet/bashplus/issues/

View file

@ -0,0 +1,77 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.41.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Name
Bash+(1) - Modern Bash Programming
=for html
<a href="https://travis-ci.org/ingydotnet/bashplus"><img src="https://travis-ci.org/ingydotnet/bashplus.png" alt="bashplus"></a>
=head1 Synopsis
source bash+ :std :array
use Foo::Bar this that
Array.new args "$@"
if args.empty?; then
die "I need args!"
fi
Foo::Bar.new foo args
this is awesome # <= this is a real command! (You just imported it)
=head1 Description
Bash+ is just Bash... B<plus> some libraries that can make Bash programming a
lot nicer.
=for comment # Installation
Get the source code from GitHub:
git clone git@github.com:ingydotnet/bashplus
Then run:
make test
make install # Possibly with 'sudo'
=head1 Usage
For now look at some libraries the use Bash+:
=over
=item * L<https://github.com/ingydotnet/git-hub>
=item * L<https://github.com/ingydotnet/json-bash>
=item * L<https://github.com/ingydotnet/test-more-bash>
=back
=head1 Status
If you are interested in chatting about this, C</join #bpan> on
irc.freenode.net.
=head1 Author
Written by Ingy döt Net <ingy@ingy.net>
=head1 Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).
=cut

View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# Bash+ - Modern Bash Programming
#
# Copyright (c) 2013-2016 Ingy döt Net
#------------------------------------------------------------------------------
set -e
shopt -s compat31&>/dev/null||:
#------------------------------------------------------------------------------
# Determine how `bash+` was called, and do the right thing:
#------------------------------------------------------------------------------
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
# 'bash+' is being sourced:
[[ "${BASH_SOURCE[0]}" =~ /bin/bash\\+$ ]] || {
echo "Invalid Bash+ path '${BASH_SOURCE[0]}'" 2> /dev/null
exit 1
}
source "${BASH_SOURCE[0]%/bin/*}"/lib/bash+.bash || return $?
bash+:import "$@"
return $?
else
if [ $# -eq 1 -a "$1" == --version ]; then
echo 'bash+ version 0.0.7'
else
cat <<...
Greetings modern Bash programmer. Welcome to Bash+!
Bash+ is framework that makes Bash programming more like Ruby and Perl.
See: https://github.com/bpan-org/bashplus
If you got here trying to use bash+ in a program, you need to source it:
source bash+
Happy Bash Hacking!
...
fi
fi

View file

@ -0,0 +1,61 @@
Bash+(1)
========
Modern Bash Programming
<badge travis ingydotnet/bashplus>
= Synopsis
source bash+ :std :array
use Foo::Bar this that
Array.new args "$@"
if args.empty?; then
die "I need args!"
fi
Foo::Bar.new foo args
this is awesome # <= this is a real command! (You just imported it)
= Description
Bash+ is just Bash... *plus* some libraries that can make Bash programming a
lot nicer.
## Installation
Get the source code from GitHub:
git clone git@github.com:ingydotnet/bashplus
Then run:
make test
make install # Possibly with 'sudo'
= Usage
For now look at some libraries the use Bash+:
* https://github.com/ingydotnet/git-hub
* https://github.com/ingydotnet/json-bash
* https://github.com/ingydotnet/test-more-bash
= Status
If you are interested in chatting about this, `/join #bpan` on
irc.freenode.net.
= Author
Written by Ingy döt Net <ingy@ingy.net>
= Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).

View file

@ -0,0 +1,134 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Bash+(1) 1"
.TH Bash+(1) 1 "January 2016" "Generated by Swim v0.1.41" "Modern Bash Programming"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "Name"
.IX Header "Name"
Bash+(1) \- Modern Bash Programming
.SH "Synopsis"
.IX Header "Synopsis"
.Vb 1
\& source bash+ :std :array
\&
\& use Foo::Bar this that
\&
\& Array.new args "$@"
\&
\& if args.empty?; then
\& die "I need args!"
\& fi
\&
\& Foo::Bar.new foo args
\&
\& this is awesome # <= this is a real command! (You just imported it)
.Ve
.SH "Description"
.IX Header "Description"
Bash+ is just Bash... \fBplus\fR some libraries that can make Bash programming a lot nicer.
.PP
Get the source code from GitHub:
.PP
.Vb 1
\& git clone git@github.com:ingydotnet/bashplus
.Ve
.PP
Then run:
.PP
.Vb 2
\& make test
\& make install # Possibly with \*(Aqsudo\*(Aq
.Ve
.SH "Usage"
.IX Header "Usage"
For now look at some libraries the use Bash+:
.IP "\(bu" 4
<https://github.com/ingydotnet/git\-hub>
.IP "\(bu" 4
<https://github.com/ingydotnet/json\-bash>
.IP "\(bu" 4
<https://github.com/ingydotnet/test\-more\-bash>
.SH "Status"
.IX Header "Status"
If you are interested in chatting about this, \f(CW\*(C`/join #bpan\*(C'\fR on irc.freenode.net.
.SH "Author"
.IX Header "Author"
Written by Ingy döt Net <ingy@ingy.net>
.SH "Copyright & License"
.IX Header "Copyright & License"
Copyright 2013\-2016. Ingy döt Net.
.PP
The \s-1MIT\s0 License (\s-1MIT\s0).

View file

@ -0,0 +1,134 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Bash+(1) 1"
.TH Bash+(1) 1 "January 2016" "Generated by Swim v0.1.41" "Modern Bash Programming"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "Name"
.IX Header "Name"
Bash+(1) \- Modern Bash Programming
.SH "Synopsis"
.IX Header "Synopsis"
.Vb 1
\& source bash+ :std :array
\&
\& use Foo::Bar this that
\&
\& Array.new args "$@"
\&
\& if args.empty?; then
\& die "I need args!"
\& fi
\&
\& Foo::Bar.new foo args
\&
\& this is awesome # <= this is a real command! (You just imported it)
.Ve
.SH "Description"
.IX Header "Description"
Bash+ is just Bash... \fBplus\fR some libraries that can make Bash programming a lot nicer.
.PP
Get the source code from GitHub:
.PP
.Vb 1
\& git clone git@github.com:ingydotnet/bashplus
.Ve
.PP
Then run:
.PP
.Vb 2
\& make test
\& make install # Possibly with \*(Aqsudo\*(Aq
.Ve
.SH "Usage"
.IX Header "Usage"
For now look at some libraries the use Bash+:
.IP "\(bu" 4
<https://github.com/ingydotnet/git\-hub>
.IP "\(bu" 4
<https://github.com/ingydotnet/json\-bash>
.IP "\(bu" 4
<https://github.com/ingydotnet/test\-more\-bash>
.SH "Status"
.IX Header "Status"
If you are interested in chatting about this, \f(CW\*(C`/join #bpan\*(C'\fR on irc.freenode.net.
.SH "Author"
.IX Header "Author"
Written by Ingy döt Net <ingy@ingy.net>
.SH "Copyright & License"
.IX Header "Copyright & License"
Copyright 2013\-2016. Ingy döt Net.
.PP
The \s-1MIT\s0 License (\s-1MIT\s0).

View file

@ -0,0 +1,12 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std
ok $? '`source bash+` works'
is "$BASHPLUS_VERSION" '0.0.7' 'BASHPLUS_VERSION is 0.0.7'
done_testing 2

View file

@ -0,0 +1,22 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+
foo() {
echo O HAI
}
like "$(type bar 2>&1)" 'bar: not found' \
'bar is not yet a function'
bash+:fcopy foo bar
type -t bar &>/dev/null
ok $? 'bar is now a function'
is "$(type foo | tail -n+3)" "$(type bar | tail -n+3)" \
'Copy matches original'
done_testing 3

View file

@ -0,0 +1,18 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std
ok "`bash+:can use`" 'use is imported'
ok "`bash+:can die`" 'die is imported'
ok "`bash+:can warn`" 'warn is imported'
ok "`! bash+:can import`" 'import is not imported'
ok "`! bash+:can main`" 'main is not imported'
ok "`! bash+:can fcopy`" 'fcopy is not imported'
ok "`! bash+:can findlib`" 'findlib is not imported'
ok "`! bash+:can can`" 'can is not imported'
done_testing 8

View file

@ -0,0 +1,23 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+
functions=(
use
import
fcopy
findlib
die
warn
can
)
for f in ${functions[@]}; do
is "$(type -t "bash+:$f")" function \
"bash+:$f is a function"
done
done_testing 7

View file

@ -0,0 +1,70 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# This is a tiny version of test-more-bash that I use here. test-more-bash uses
# bash+, so I want to avoid the circular dependency. This little guy does
# 80-90% what test-more-bash does, with minimal code. It's a good example of
# how nice Bash can be.
#------------------------------------------------------------------------------
plan() {
echo "1..$1"
}
pass() {
let run=run+1
echo "ok $run${1:+ - $1}"
}
fail() {
let run=run+1
echo "not ok $run${1:+ - $1}"
}
is() {
if [ "$1" == "$2" ]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Want: $2"
fi
}
ok() {
(exit ${1:-$?}) &&
pass "$2" ||
fail "$2"
}
like() {
if [[ "$1" =~ "$2" ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Like: $2"
fi
}
unlike() {
if [[ ! "$1" =~ "$2" ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Dont: $2"
fi
}
done_testing() {
echo "1..${1:-$run}"
}
diag() {
echo "# ${1//$'\n'/$'\n'# }" >&2
}
note() {
echo "# ${1//$'\n'/$'\n'# }"
}

View file

@ -0,0 +1,19 @@
#!/bin/bash -e
source test/test.bash
PATH=$PWD/bin:$PATH
source bash+ :std can
BASHLIB=test/lib
use Foo::Bar
ok $? 'use Foo::Bar - works'
ok "`can Foo::Bar:baz`" 'Function Foo::Bar:baz exists'
is "$Foo__Bar_VERSION" 1.2.3 '$Foo__Bar_VERSION == 1.2.3'
output=`use Foo::Foo Boo Booo`
ok $? 'use Foo::Foo Boo Booo - works'
is "$output" Boo---Booo 'Correct import called'
done_testing 5

View file

@ -0,0 +1,11 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = git@github.com:ingydotnet/test-tap-bash.git
branch = master
commit = 7890df93f13e684715750a2d6a608e7e79671ca4
parent = 3faca582ee96a320b5675ad67b47ad0f16730446
cmdver = 0.3.0

View file

@ -0,0 +1,6 @@
# C language gives closest shell env.
language: c
script:
- git submodule update --init --recursive
- PROVEOPT=-v make test

View file

@ -0,0 +1,15 @@
---
version: 0.0.4
date: Sat Jan 23 16:32:22 PST 2016
changes:
- Make up to date.
---
version: 0.0.3
date: Fri Jan 23 21:39:39 PST 2015
changes:
- Make up to date.
---
version: 0.0.1
date: Sun Oct 27 23:02:11 PDT 2013
changes:
- First release.

View file

@ -0,0 +1,21 @@
(The MIT License)
Copyright © 2013-2016. Ingy döt Net.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the Software), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,37 @@
ifeq ($(MAKECMDGOALS),install)
ifeq "$(shell bpan version 2>/dev/null)" ""
$(error 'BPAN not installed. See http://bpan.org')
endif
endif
NAME := test-tap
LIB := lib/test/tap.bash
MAN3 := man/man3
INSTALL_LIB ?= $(shell bpan env BPAN_LIB)
INSTALL_DIR ?= test
INSTALL_MAN3 ?= $(shell bpan env BPAN_MAN3)
default: help
help:
@echo 'Rules: test, install, doc'
.PHONY: test
test:
prove $(PROVEOPT:%=% )test/
install:
install -C -d -m 0755 $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -m 0755 $(LIB) $(INSTALL_LIB)/$(INSTALL_DIR)/
install -C -d -m 0755 $(INSTALL_MAN3)/
install -C -m 0644 $(MAN3)/$(NAME).3 $(INSTALL_MAN3)/
.PHONY: doc
doc: ReadMe.pod $(MAN3)/$(NAME).3
ReadMe.pod: doc/test-tap.swim
swim --to=pod --complete --wrap $< > $@
man/man3/%.3: doc/%.swim
swim --to=man $< > $@

View file

@ -0,0 +1,28 @@
=meta: 0.0.2
name: test-tap
version: 0.0.4
abstract: TAP Test Base for Bash
homepage: http://bpan.org/package/test-tap/
license: MIT
copyright: 2013-2016
author:
name: Ingy döt Net
email: ingy@ingy.net
github: ingydotnet
twitter: ingydotnet
freenode: ingy
homepage: http://ingy.net
requires:
bash: 3.2.0
test:
cmd: make test
install:
cmd: make install
devel:
git: git@github.org/ingydotnet/test-tap-bash.git
irc: irc.freenode.net/bpan
bug: https://github.com/ingydotnet/test-tap-bash/issues/

View file

@ -0,0 +1,66 @@
=pod
=for comment
DO NOT EDIT. This Pod was generated by Swim v0.1.41.
See http://github.com/ingydotnet/swim-pm#readme
=encoding utf8
=head1 Name
Test::Tap - TAP Test Base for Bash
=for html
<a href="https://travis-ci.org/ingydotnet/test-tap-bash"><img src="https://travis-ci.org/ingydotnet/test-tap-bash.png" alt="test-tap-bash"></a>
=head1 Synopsis
source test/tap.bash
Test::Tap:plan tests 1
pass 'Everything is OK!'
=head1 Description
This is a TAP testing base class for Bash. It has all the basic TAP functions,
and works properly from a TAP harness, like the C<prove> utility.
test-tap-bash is used as the base for test-more-bash, which is what you want
if you are writing tests in bash.
See: L<https://github.com/ingydotnet/test-more-bash/>
=head1 Functions
=over
=item C<Test::Tap:init>
Must be called first for every test file/process.
=item C<Test::Tap::plan>
Used to set the plan.
=back
=head1 TODO
=over
=item * Finish this doc.
=back
=head1 Author
Written by Ingy döt Net <ingy@ingy.net>
=head1 Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).
=cut

View file

@ -0,0 +1,48 @@
Test::Tap
=========
TAP Test Base for Bash
<badge travis ingydotnet/test-tap-bash>
= Synopsis
source test/tap.bash
Test::Tap:plan tests 1
pass 'Everything is OK!'
= Description
This is a TAP testing base class for Bash. It has all the basic TAP functions,
and works properly from a TAP harness, like the `prove` utility.
test-tap-bash is used as the base for test-more-bash, which is what you want
if you are writing tests in bash.
See: https://github.com/ingydotnet/test-more-bash/
= Functions
- `Test::Tap:init`
Must be called first for every test file/process.
- `Test::Tap::plan`
Used to set the plan.
= TODO
* Finish this doc.
= Author
Written by Ingy döt Net <ingy@ingy.net>
= Copyright & License
Copyright 2013-2016. Ingy döt Net.
The MIT License (MIT).

View file

@ -0,0 +1,119 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Test::Tap 1"
.TH Test::Tap 1 "January 2016" "Generated by Swim v0.1.41" "\s-1TAP\s0 Test Base for Bash"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "Name"
.IX Header "Name"
Test::Tap \- \s-1TAP\s0 Test Base for Bash
.SH "Synopsis"
.IX Header "Synopsis"
.Vb 1
\& source test/tap.bash
\&
\& Test::Tap:plan tests 1
\&
\& pass \*(AqEverything is OK!\*(Aq
.Ve
.SH "Description"
.IX Header "Description"
This is a \s-1TAP\s0 testing base class for Bash. It has all the basic \s-1TAP\s0 functions, and works properly from a \s-1TAP\s0 harness, like the \f(CW\*(C`prove\*(C'\fR utility.
.PP
test-tap-bash is used as the base for test-more-bash, which is what you want if you are writing tests in bash.
.PP
See: <https://github.com/ingydotnet/test\-more\-bash/>
.SH "Functions"
.IX Header "Functions"
.ie n .IP """Test::Tap:init""" 4
.el .IP "\f(CWTest::Tap:init\fR" 4
.IX Item "Test::Tap:init"
Must be called first for every test file/process.
.ie n .IP """Test::Tap::plan""" 4
.el .IP "\f(CWTest::Tap::plan\fR" 4
.IX Item "Test::Tap::plan"
Used to set the plan.
.SH "TODO"
.IX Header "TODO"
.IP "\(bu" 4
Finish this doc.
.SH "Author"
.IX Header "Author"
Written by Ingy döt Net <ingy@ingy.net>
.SH "Copyright & License"
.IX Header "Copyright & License"
Copyright 2013\-2016. Ingy döt Net.
.PP
The \s-1MIT\s0 License (\s-1MIT\s0).

View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
source test/helper.bash
source lib/test/tap.bash
Test::Tap:init tests 1
output=$(prove -v test/test/{b,f}ail.t 2>&1)
test-helper:like \
"$output" \
'Bailout called. Further testing stopped: Get me outta here' \
'Test::Tap:BAIL_OUT works'

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
source lib/test/tap.bash
Test::Tap:init
Test::Tap:pass one
Test::Tap:pass two
Test::Tap:done_testing

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
source test/helper.bash
source lib/test/tap.bash
Test::Tap:init tests 2
output="$(prove -v test/test/fail.t 2>&1)"
# echo "# >>>${output//$'\n'/$'\n'# }<<<" >&2
test-helper:like \
"$output" \
'not ok 1 - I am a failure' \
'Test::Tap:fail works'
test-helper:like \
"$output" \
'Failed 1/1 subtests' \
'Proper summary'

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
source test/helper.bash
source lib/test/tap.bash
Test::Tap:init tests 1
output="$(prove -v test/test/fail_fast.t 2>&1)"
# echo ">>>$output<<<" >&2
test-helper:like \
"$output" \
'Further testing stopped: Bailing out on status=1' \
'Test::Tap:BAIL_OUT works'

View file

@ -0,0 +1,9 @@
test-helper:like() {
local got=$1 regex=$2 label=$3
if [[ "$got" =~ "$regex" ]]; then
Test::Tap:pass "$label"
else
Test::Tap:fail "$label"
Test::Tap:diag "Got: '$got'"
fi
}

View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
source lib/test/tap.bash
Test::Tap:init tests 3
Test::Tap:pass 'pass 1 - with label'
Test::Tap:pass
Test::Tap:pass 'pass 3 - 2 has no label'

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
source lib/test/tap.bash
Test::Tap:init
Test::Tap:plan tests 3
for n in 1 2 3; do
Test::Tap:pass "Test #$n"
done

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
source test/helper.bash
source lib/test/tap.bash
Test::Tap:init tests 4
for s in plan init; do
output=$(prove test/test/skip-all-$s.t)
test-helper:like \
"$output" \
"skipped: Test for skip_all from $s" \
"skip_all from $s: it works"
test-helper:like \
"$output" \
'Result: NOTESTS' \
"skip_all from $s: No tests run"
done

Some files were not shown because too many files have changed in this diff Show more