Skip to content

Commit 0ea14d1

Browse files
authored
Merge pull request #157 from Microsoft/dev
Merge latest dev to master
2 parents c553d01 + 33bec96 commit 0ea14d1

File tree

31 files changed

+369
-328
lines changed

31 files changed

+369
-328
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Visual Studio Team services](https://mseng.visualstudio.com/_apis/public/build/definitions/698eacea-9ea2-4eb8-80a4-d06170edf6bc/5908/badge)]()
1+
[![Visual Studio Team services](https://mseng.visualstudio.com/_apis/public/build/definitions/698eacea-9ea2-4eb8-80a4-d06170edf6bc/5908/badge)](https://mseng.visualstudio.com/vsts-cli/_build/index?context=mine&path=%5C&definitionId=6169&_a=completed)
22
[![Python](https://img.shields.io/pypi/pyversions/vsts-cli.svg)](https://pypi.python.org/pypi/vsts-cli)
33

44
# Microsoft Visual Studio Team Services CLI
@@ -46,6 +46,10 @@ Create a personal access token and provide to the VSTS CLI via the login command
4646
vsts login --instance https://MYACCOUNT.visualstudio.com --token MYTOKEN
4747
```
4848

49+
### Using VSTS CLI Behind a Proxy
50+
51+
The VSTS CLI picks the network proxy configuration from the environment variables `HTTP_PROXY`, and `HTTPS_PROXY`.
52+
4953
### Configure defaults, Git aliases, and more
5054

5155
You can change your default settings using the `vsts configure` command, for example you can set the default output format for all commands. The options are:

packaged_releases/windows/scripts/build_local.cmd

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ set "PATH=%PATH%;%ProgramFiles%\Git\bin;%ProgramFiles%\Git\usr\bin"
1010

1111
if "%CLIVERSION%"=="" (
1212
if "%BUILD_BUILDID%" == "" (
13-
set CLIVERSION=0.1.0
13+
set CLIVERSION=0.1.1
1414
) else (
15-
set CLIVERSION=0.1.0.%BUILD_BUILDID%
15+
set CLIVERSION=0.1.1.%BUILD_BUILDID%
1616
)
1717
)
1818
set PYTHON_VERSION=3.6.3
@@ -25,7 +25,10 @@ set OUTPUT_DIR=%~dp0..\out
2525
if exist "%OUTPUT_DIR%" (
2626
echo Deleting directory: %OUTPUT_DIR%
2727
rmdir /s /q "%OUTPUT_DIR%"
28-
if %errorlevel% neq 0 goto ERROR
28+
)
29+
if exist "%OUTPUT_DIR%" (
30+
echo Failed to delete directory: %OUTPUT_DIR%
31+
goto ERROR
2932
)
3033

3134
echo Creating output directory: %OUTPUT_DIR%
@@ -83,6 +86,7 @@ mkdir %BUILDING_DIR%
8386
if %errorlevel% neq 0 goto ERROR
8487

8588
if exist "%TEMP_SCRATCH_FOLDER%" rmdir /s /q "%TEMP_SCRATCH_FOLDER%"
89+
8690
if exist "%TEMP_SCRATCH_FOLDER%" (
8791
echo Failed to delete %TEMP_SCRATCH_FOLDER%.
8892
goto ERROR
@@ -93,21 +97,11 @@ if %errorlevel% neq 0 goto ERROR
9397
::ensure wix is available
9498
if exist "%WIX_DIR%" (
9599
echo *** Using existing Wix at %WIX_DIR%
100+
) else (
101+
goto INSTALLWIX
96102
)
97-
if not exist "%WIX_DIR%" (
98-
mkdir "%WIX_DIR%"
99-
if %errorlevel% neq 0 goto ERROR
100-
pushd "%WIX_DIR%"
101-
echo *** Downloading Wix.
102-
curl -o wix-archive.zip %WIX_DOWNLOAD_URL% -k
103-
if %errorlevel% neq 0 goto ERROR
104-
unzip -q wix-archive.zip
105-
if %errorlevel% neq 0 goto ERROR
106-
del wix-archive.zip
107-
if %errorlevel% neq 0 goto ERROR
108-
echo *** Wix downloaded and extracted successfully.
109-
popd
110-
)
103+
104+
:WIXINSTALLED
111105

112106
:: Use the Python version on the machine that creates the MSI
113107
robocopy %PYTHON_DIR% "%BUILDING_DIR%" /s /NFL /NDL
@@ -173,9 +167,26 @@ if "%msbuildpath%" == "" (
173167
"%msbuildpath%" /t:rebuild /p:Configuration=Release "%REPO_ROOT%\packaged_releases\windows\vsts-cli.wixproj"
174168
if %errorlevel% neq 0 goto ERROR
175169

176-
start "%OUTPUT_DIR%"
170+
dir /s /b "%OUTPUT_DIR%"\*.msi
171+
172+
goto end
173+
174+
:INSTALLWIX
175+
176+
mkdir "%WIX_DIR%"
177+
if %errorlevel% neq 0 goto ERROR
178+
pushd "%WIX_DIR%"
179+
echo *** Downloading Wix.
180+
curl -o wix-archive.zip %WIX_DOWNLOAD_URL% -k
181+
if %errorlevel% neq 0 goto ERROR
182+
unzip -q wix-archive.zip
183+
if %errorlevel% neq 0 goto ERROR
184+
del wix-archive.zip
185+
if %errorlevel% neq 0 goto ERROR
186+
echo *** Wix downloaded and extracted successfully.
187+
popd
177188

178-
goto END
189+
GOTO WIXINSTALLED
179190

180191
:ERROR
181192
echo Error occurred, please check the output for details.

scripts/dev_setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def exec_command(command):
2525
print(err, file=sys.stderr)
2626
sys.exit(1)
2727

28+
29+
exec_command('python -m pip install --upgrade pip')
30+
exec_command('python -m pip install --upgrade wheel')
31+
2832
packages = []
2933

3034
# VSTS Python SDK package (from either local directory or latest)

scripts/generate_command_inventory.py

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,10 @@
1111
import sys
1212
import os
1313

14-
1514
from knack import CLI
1615
from vsts.cli.vsts_cli_help import VstsCLIHelp
1716
from vsts.cli.vsts_commands_loader import VstsCommandsLoader
1817

19-
class Exporter(json.JSONEncoder):
20-
21-
def default(self, o):#pylint: disable=method-hidden
22-
try:
23-
return super(Exporter, self).default(o)
24-
except TypeError:
25-
return str(o)
26-
27-
parser = argparse.ArgumentParser(description='Command Table Parser')
28-
parser.add_argument('--commands', metavar='N', nargs='+', help='Filter by first level command (OR)')
29-
parser.add_argument('--params', metavar='N', nargs='+', help='Filter by parameters (OR)')
30-
args = parser.parse_args()
31-
cmd_set_names = args.commands
32-
param_names = args.params
33-
3418
# ignore the params passed in now so they aren't used by the cli
3519
sys.argv = sys.argv[:1]
3620

@@ -43,30 +27,26 @@ def default(self, o):#pylint: disable=method-hidden
4327

4428
loader = vstscli.commands_loader_cls()
4529
loader.__init__(vstscli)
46-
loader.load_command_table([])
30+
cmd_table = loader.load_command_table([])
4731
for command in loader.command_table:
4832
loader.load_arguments(command)
4933

50-
cmd_table = loader.load_command_table([])
51-
cmd_list = [cmd_name for cmd_name in cmd_table.keys() if cmd_set_names is None or cmd_name.split()[0] in cmd_set_names]
52-
results = []
34+
vstsclihelp = vstscli.help_cls(cli_ctx=vstscli)
35+
36+
global_parser = vstscli.parser_cls.create_global_parser(cli_ctx=vstscli)
37+
parser = vstscli.parser_cls(cli_ctx=vstscli, prog=vstscli.name, parents=[global_parser])
38+
parser.load_command_table(cmd_table)
39+
40+
cmd_list = cmd_table.keys()
41+
42+
results = {}
43+
44+
for cmd_name in cmd_list:
45+
cmd_args = cmd_table[cmd_name].arguments
46+
args = []
47+
for arg in cmd_args:
48+
args.append(arg)
49+
results[cmd_name] = args
5350

54-
if param_names:
55-
for name in cmd_list:
56-
cmd_name = [x for x in cmd_table.keys() if name == x][0]
57-
cmd_args = cmd_table[cmd_name]['arguments']
58-
match = False
59-
for arg in cmd_args:
60-
if match:
61-
break
62-
arg_name = re.sub('--','', arg['name']).split(' ')[0]
63-
if arg_name in param_names:
64-
results.append(name)
65-
match = True
66-
else:
67-
results = cmd_list
51+
print(json.dumps(results, indent=1))
6852

69-
heading = '=== COMMANDS IN {} PACKAGE(S) WITH {} PARAMETERS ==='.format(
70-
cmd_set_names or 'ANY', param_names or 'ANY')
71-
print('\n{}\n'.format(heading))
72-
print('\n'.join(results))

scripts/windows/init.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ param (
55
$tempFile = [IO.Path]::GetTempFileName()
66
cmd.exe /C "$PSScriptRoot\init.cmd && set>$tempFile"
77
$lines = [System.IO.File]::ReadAllLines("$tempFile")
8-
$curLoc = get-location
9-
$lines|ForEach-Object -Begin { set-location env: } -End { set-location $curLoc } -Process {
8+
$curLoc = Get-Location
9+
$lines | ForEach-Object -Begin { Set-Location env: } -End { Set-Location $curLoc } -Process {
1010
$var = $_.Split('=')
1111
if ($var.length -gt 1 -and $var[0] -ne "") {
12-
set-item -path $var[0] -value $var[1]
12+
Set-Item -path $var[0] -value $var[1]
1313
}
1414
}
15-
remove-item $tempFile
15+
Remove-Item $tempFile
1616

1717
# Set up aliases
1818

@@ -24,10 +24,10 @@ if ((Get-Module PSReadLine) -and ($KeepPsReadLine -eq $false)) {
2424
Remove-Module PSReadLine
2525

2626
# note: using doskey because Set-Alias is not as powerful
27-
# NOTE commands in macros.txt work in both Powershell and cmd. Keep it that way!
28-
# Only add macros to macros.ps.txt when the same macro cannot be used in both Powershell and cmd.
27+
# NOTE commands in macros.txt work in both PowerShell and cmd. Keep it that way!
28+
# Only add macros to macros.ps.txt when the same macro cannot be used in both PowerShell and cmd.
2929
# In that case, add equivalent macros to both macros.ps.txt and macros.cmd.txt, to ensure that
30-
# the Powershell and cmd development environments remain functionally identical.
30+
# the PowerShell and cmd development environments remain functionally identical.
3131
doskey /exename=powershell.exe /MACROFILE="$PSScriptRoot\macros.txt"
3232
doskey /exename=powershell.exe /MACROFILE="$PSScriptRoot\macros.ps.txt"
3333
}

src/command_modules/vsts-cli-build/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import setup, find_packages
77

88
NAME = 'vsts-cli-build'
9-
VERSION = '0.1.0b3'
9+
VERSION = '0.1.1'
1010

1111
# To install the library, run the following
1212
#
@@ -16,8 +16,8 @@
1616
# http://pypi.python.org/pypi/setuptools
1717

1818
REQUIRES = [
19-
'knack==0.2.0',
20-
'python-dateutil',
19+
'knack==0.3.3',
20+
'python-dateutil==2.7.3',
2121
'vsts-cli-build-common==' + VERSION
2222
]
2323

src/command_modules/vsts-cli-build/vsts/cli/build/_format.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
from collections import OrderedDict
11-
from vsts.cli.common.git import REF_HEADS_PREFIX
1211

1312

1413
def transform_builds_table_output(result):
@@ -24,6 +23,7 @@ def transform_build_table_output(result):
2423

2524

2625
def _transform_build_row(row):
26+
from vsts.cli.common.git import REF_HEADS_PREFIX
2727
table_row = OrderedDict()
2828
table_row['ID'] = row['id']
2929
table_row['Number'] = row['buildNumber']
@@ -34,10 +34,15 @@ def _transform_build_row(row):
3434
table_row['Result'] = ' '
3535
table_row['Definition ID'] = row['definition']['id']
3636
table_row['Definition Name'] = row['definition']['name']
37-
source_branch = row['sourceBranch']
38-
if source_branch[0:len(REF_HEADS_PREFIX)] == REF_HEADS_PREFIX:
39-
source_branch = source_branch[len(REF_HEADS_PREFIX):]
40-
table_row['Source Branch'] = source_branch
37+
38+
if row['sourceBranch']:
39+
source_branch = row['sourceBranch']
40+
if source_branch[0:len(REF_HEADS_PREFIX)] == REF_HEADS_PREFIX:
41+
source_branch = source_branch[len(REF_HEADS_PREFIX):]
42+
table_row['Source Branch'] = source_branch
43+
else:
44+
table_row['Source Branch'] = ' '
45+
4146
queued_time = dateutil.parser.parse(row['queueTime']).astimezone(dateutil.tz.tzlocal())
4247
table_row['Queued Time'] = str(queued_time.date()) + ' ' + str(queued_time.time())
4348
table_row['Reason'] = row['reason']

src/command_modules/vsts-cli-build/vsts/cli/build/arguments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def load_build_arguments(cli_command_loader):
2222

2323
with ArgumentsContext(cli_command_loader, 'build queue') as ac:
2424
ac.argument('definition_id', type=int)
25+
ac.argument('variables', nargs='*')
2526

2627
with ArgumentsContext(cli_command_loader, 'build show') as ac:
2728
ac.argument('build_id', options_list='--id', type=int)

src/command_modules/vsts-cli-build/vsts/cli/build/commands.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
transform_builds_table_output,
88
transform_definition_table_output,
99
transform_definitions_table_output)
10-
from knack.commands import CommandSuperGroup
10+
from knack.commands import CommandGroup
1111

1212

1313
def load_build_commands(cli_command_loader):
14-
with CommandSuperGroup(__name__, cli_command_loader, 'vsts.cli.build.common.custom#{}') as sg:
15-
with sg.group('build') as g:
16-
# basic vsts_cli_build commands
17-
g.command('list', 'build_list',
18-
table_transformer=transform_builds_table_output)
19-
g.command('queue', 'build_queue',
20-
table_transformer=transform_build_table_output)
21-
g.command('show', 'build_show',
22-
table_transformer=transform_build_table_output)
14+
with CommandGroup(cli_command_loader, 'build', 'vsts.cli.build.common.{}') as g:
15+
# basic vsts_cli_build commands
16+
g.command('list', 'build#build_list',
17+
table_transformer=transform_builds_table_output)
18+
g.command('queue', 'build#build_queue',
19+
table_transformer=transform_build_table_output)
20+
g.command('show', 'build#build_show',
21+
table_transformer=transform_build_table_output)
2322

24-
# basic vsts_cli_build definition commands
25-
g.command('definition list', 'build_definition_list',
26-
table_transformer=transform_definitions_table_output)
27-
g.command('definition show', 'build_definition_show',
28-
table_transformer=transform_definition_table_output)
23+
# basic vsts_cli_build definition commands
24+
g.command('definition list', 'build_definition#build_definition_list',
25+
table_transformer=transform_definitions_table_output)
26+
g.command('definition show', 'build_definition#build_definition_show',
27+
table_transformer=transform_definition_table_output)

src/command_modules/vsts-cli-code/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import setup, find_packages
77

88
NAME = 'vsts-cli-code'
9-
VERSION = '0.1.0b3'
9+
VERSION = '0.1.1'
1010

1111
# To install the library, run the following
1212
#
@@ -16,8 +16,8 @@
1616
# http://pypi.python.org/pypi/setuptools
1717

1818
REQUIRES = [
19-
'knack==0.2.0',
20-
'python-dateutil',
19+
'knack==0.3.3',
20+
'python-dateutil==2.7.3',
2121
'vsts-cli-code-common==' + VERSION
2222
]
2323

src/command_modules/vsts-cli-code/vsts/cli/code/_format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
import dateutil.parser
88
import dateutil.tz
99

10-
from vsts.cli.common.identities import (ensure_display_names_in_cache,
11-
get_display_name_from_identity_id)
12-
from vsts.cli.common.git import get_branch_name_from_ref
13-
from vsts.cli.common.services import get_first_vss_instance_uri
1410

1511
_PR_TITLE_TRUNCATION_LENGTH = 50
1612
_WORK_ITEM_TITLE_TRUNCATION_LENGTH = 70
@@ -138,6 +134,9 @@ def _get_vote_from_vote_number(number):
138134

139135

140136
def transform_policies_table_output(result):
137+
from vsts.cli.common.identities import (ensure_display_names_in_cache,
138+
get_display_name_from_identity_id)
139+
from vsts.cli.common.services import get_first_vss_instance_uri
141140
table_output = []
142141
reviewer_ids = []
143142
for item in result:
@@ -241,6 +240,7 @@ def transform_repo_table_output(result):
241240

242241

243242
def _transform_repo_row(row):
243+
from vsts.cli.common.git import get_branch_name_from_ref
244244
table_row = OrderedDict()
245245
table_row['ID'] = row['id']
246246
table_row['Name'] = row['name']

0 commit comments

Comments
 (0)