All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.sbb.releasetrain.state.git.GitClientImpl Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements;
 * and to You under the Apache License, Version 2.0.
 */
package ch.sbb.releasetrain.state.git;

import java.io.File;

import org.springframework.stereotype.Component;

/**
 * @author u206123 (Florian Seidl)
 * @since 0.0.6, 2016.
 */
@Component
public class GitClientImpl implements GitClient {

    private final File tempDir;

    public GitClientImpl() {
        tempDir = new File(System.getProperty("java.io.tmpdir"));
    }

    public GitClientImpl(File tempDir) {
        this.tempDir = tempDir;
    }

    static String filenameFromUrl(final String url) {
        return url.trim().replaceAll("[\\W]", "_");
    }

    @Override
    public GitRepo gitRepo(String url, String branch, String user, String password) {
        return new GitRepoImpl(url, branch, user, password, new File(tempDir, filenameFromUrl(url)));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy