New config hide_project_names
This commit is contained in:
parent
3373ef39e4
commit
71d5eef12a
15 changed files with 165 additions and 17 deletions
5
tests/samples/configs/paranoid_projects.cfg
Normal file
5
tests/samples/configs/paranoid_projects.cfg
Normal file
|
@ -0,0 +1,5 @@
|
|||
[settings]
|
||||
debug = false
|
||||
api_key = c21f8ebd-6a6a-48a0-900b-0870db3d7afe
|
||||
api_url = https://api.wakatime.com/api/v1/heartbeats
|
||||
hide_project_names = true
|
|
@ -4,8 +4,9 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--proxy PROXY] [--no-ssl-verify] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--language LANGUAGE]
|
||||
[--hostname HOSTNAME] [--disable-offline] [--hide-filenames]
|
||||
[--exclude EXCLUDE] [--exclude-unknown-project]
|
||||
[--include INCLUDE] [--include-only-with-project-file]
|
||||
[--extra-heartbeats] [--log-file LOG_FILE] [--api-url API_URL]
|
||||
[--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version]
|
||||
[--hide-project-names] [--exclude EXCLUDE]
|
||||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: Missing api key. Find your api key from wakatime.com/settings/api-key.
|
||||
|
|
|
@ -4,8 +4,9 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--proxy PROXY] [--no-ssl-verify] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--language LANGUAGE]
|
||||
[--hostname HOSTNAME] [--disable-offline] [--hide-filenames]
|
||||
[--exclude EXCLUDE] [--exclude-unknown-project]
|
||||
[--include INCLUDE] [--include-only-with-project-file]
|
||||
[--extra-heartbeats] [--log-file LOG_FILE] [--api-url API_URL]
|
||||
[--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version]
|
||||
[--hide-project-names] [--exclude EXCLUDE]
|
||||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: Missing api key. Find your api key from wakatime.com/settings/api-key.
|
||||
|
|
|
@ -4,8 +4,9 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--proxy PROXY] [--no-ssl-verify] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--language LANGUAGE]
|
||||
[--hostname HOSTNAME] [--disable-offline] [--hide-filenames]
|
||||
[--exclude EXCLUDE] [--exclude-unknown-project]
|
||||
[--include INCLUDE] [--include-only-with-project-file]
|
||||
[--extra-heartbeats] [--log-file LOG_FILE] [--api-url API_URL]
|
||||
[--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version]
|
||||
[--hide-project-names] [--exclude EXCLUDE]
|
||||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: argument --timeout: invalid int value: 'abc'
|
||||
|
|
|
@ -4,10 +4,11 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--proxy PROXY] [--no-ssl-verify] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--language LANGUAGE]
|
||||
[--hostname HOSTNAME] [--disable-offline] [--hide-filenames]
|
||||
[--exclude EXCLUDE] [--exclude-unknown-project]
|
||||
[--include INCLUDE] [--include-only-with-project-file]
|
||||
[--extra-heartbeats] [--log-file LOG_FILE] [--api-url API_URL]
|
||||
[--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version]
|
||||
[--hide-project-names] [--exclude EXCLUDE]
|
||||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
|
||||
Common interface for the WakaTime api.
|
||||
|
||||
|
@ -49,6 +50,10 @@ optional arguments:
|
|||
--disable-offline Disables offline time logging instead of queuing
|
||||
logged time.
|
||||
--hide-filenames Obfuscate filenames. Will not send file names to api.
|
||||
--hide-project-names Obfuscate project names. When a project folder is
|
||||
detected instead of using the folder name as the
|
||||
project, a .wakatime-project file is created with a
|
||||
random project name.
|
||||
--exclude EXCLUDE Filename patterns to exclude from logging. POSIX regex
|
||||
syntax. Can be used more than once.
|
||||
--exclude-unknown-project
|
||||
|
|
|
@ -459,6 +459,46 @@ class ConfigsTestCase(TestCase):
|
|||
self.assertOfflineHeartbeatsSynced()
|
||||
self.assertSessionCacheSaved()
|
||||
|
||||
def test_obfuscte_project_names(self):
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
|
||||
|
||||
with TemporaryDirectory() as tempdir:
|
||||
shutil.copytree('tests/samples/projects/git', os.path.join(tempdir, 'git'))
|
||||
shutil.move(os.path.join(tempdir, 'git', 'dot_git'), os.path.join(tempdir, 'git', '.git'))
|
||||
entity = os.path.join(tempdir, 'git', 'emptyfile.txt')
|
||||
now = u(int(time.time()))
|
||||
config = 'tests/samples/configs/paranoid_projects.cfg'
|
||||
key = u(uuid.uuid4())
|
||||
dependencies = []
|
||||
generated_proj = 'Icy Bridge 42'
|
||||
|
||||
args = ['--file', entity, '--key', key, '--config', config, '--time', now, '--log-file', '~/.wakatime.log']
|
||||
|
||||
with mock.patch('wakatime.project.generate_project_name') as mock_proj:
|
||||
mock_proj.return_value = generated_proj
|
||||
|
||||
retval = execute(args)
|
||||
|
||||
self.assertEquals(retval, SUCCESS)
|
||||
self.assertNothingPrinted()
|
||||
|
||||
heartbeat = {
|
||||
'language': 'Text only',
|
||||
'lines': 0,
|
||||
'entity': os.path.realpath(entity),
|
||||
'project': generated_proj,
|
||||
'time': float(now),
|
||||
'is_write': False,
|
||||
'type': 'file',
|
||||
'dependencies': dependencies,
|
||||
'user_agent': ANY,
|
||||
}
|
||||
self.assertHeartbeatSent(heartbeat)
|
||||
|
||||
self.assertHeartbeatNotSavedOffline()
|
||||
self.assertOfflineHeartbeatsSynced()
|
||||
self.assertSessionCacheSaved()
|
||||
|
||||
@log_capture()
|
||||
def test_exclude_file(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
|
|
@ -15,6 +15,7 @@ from testfixtures import log_capture
|
|||
from wakatime.compat import u, open
|
||||
from wakatime.constants import API_ERROR, SUCCESS
|
||||
from wakatime.exceptions import NotYetImplemented
|
||||
from wakatime.project import generate_project_name
|
||||
from wakatime.projects.base import BaseProject
|
||||
from wakatime.projects.git import Git
|
||||
from .utils import ANY, DynamicIterable, TestCase, TemporaryDirectory, CustomResponse, mock, json
|
||||
|
@ -723,3 +724,7 @@ class ProjectTestCase(TestCase):
|
|||
self.assertNothingPrinted()
|
||||
self.assertNothingLogged(logs)
|
||||
self.assertEquals('proj-arg', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
|
||||
|
||||
def test_generate_project_name(self):
|
||||
self.assertGreater(len(generate_project_name()), 1)
|
||||
self.assertNotEqual(generate_project_name(), generate_project_name())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue