Skip to content

Commit

Permalink
Detect special POSIX shells on Windows and output POSIX paths (#203)
Browse files Browse the repository at this point in the history
* Detect special POSIX shells on Windows and output POSIX paths

Signed-off-by: Christophe Bedard <[email protected]>

* address linter errors

* modify debug message to not show on platform not affected

Co-authored-by: Dirk Thomas <[email protected]>
  • Loading branch information
christophebedard and dirk-thomas authored Apr 14, 2021
1 parent 7d1329f commit f6cc45c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions vcstool/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@
logging.basicConfig()


# Detect special Windows shells that do not support mixes of
# backslashes & forward slashes; for those shells, we want to
# output POSIX paths, i.e. forward slashes only
windows_force_posix = \
sys.platform == 'win32' and '/' in os.environ.get('_', '')


def fix_output_path(path):
global windows_force_posix
return path.replace('\\', '/') if windows_force_posix else path


def output_repositories(clients):
from vcstool.streams import stdout
ordered_clients = {client.path: client for client in clients}
for k in sorted(ordered_clients.keys()):
client = ordered_clients[k]
print('%s (%s)' % (k, client.__class__.type), file=stdout)
print(
'%s (%s)' % (fix_output_path(k), client.__class__.type),
file=stdout)


def generate_jobs(clients, command):
Expand Down Expand Up @@ -67,10 +81,14 @@ def get_ready_job(jobs):
def execute_jobs(
jobs, show_progress=False, number_of_workers=10, debug_jobs=False
):
global windows_force_posix
from vcstool.streams import stdout
if debug_jobs:
logger.setLevel(logging.DEBUG)

if windows_force_posix:
logger.debug('force POSIX paths on Windows')

results = []

job_queue = Queue()
Expand Down Expand Up @@ -223,7 +241,7 @@ def output_result(result, hide_empty=False):
client = result['client']
print(
ansi('bluef') + '=== ' +
ansi('boldon') + client.path + ansi('boldoff') +
ansi('boldon') + fix_output_path(client.path) + ansi('boldoff') +
' (' + client.__class__.type + ') ===' + ansi('reset'),
file=stdout)
if output:
Expand Down

0 comments on commit f6cc45c

Please sign in to comment.