move some things inside the if-block
move some things inside the if-block

no need to set if we're not gonna use it
Also remove redundant chdir and getcwd call

sebbASF/infrastructure-puppet,sebbASF/infrastructure-puppet,apache/infrastructure-puppet,sebbASF/infrastructure-puppet,sebbASF/infrastructure-puppet,sebbASF/infrastructure-puppet,sebbASF/infrastructure-puppet,apache/infrastructure-puppet,apache/infrastructure-puppet,sebbASF/infrastructure-puppet,apache/infrastructure-puppet,apache/infrastructure-puppet,apache/infrastructure-puppet,sebbASF/infrastructure-puppet,apache/infrastructure-puppet