// Path: src/main/java/org/commonwl/view/researchobject/HashableAgent.java
// public class HashableAgent extends Agent {
// 
//     private String name;
//     private URI orcid;
//     private URI uri;
// 
//     public HashableAgent() {}
// 
//     public HashableAgent(String name, URI orcid, URI uri) {
//         this.name = name;
//         this.orcid = orcid;
//         this.uri = uri;
//     }
// 
//     @Override
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public URI getOrcid() {
//         return orcid;
//     }
// 
//     @Override
//     public void setOrcid(URI orcid) {
//         this.orcid = orcid;
//     }
// 
//     @Override
//     public URI getUri() {
//         return uri;
//     }
// 
//     @Override
//     public void setUri(URI uri) {
//         this.uri = uri;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass() || super.getClass() != o.getClass()) return false;
// 
//         HashableAgent that = (HashableAgent) o;
// 
//         // ORCID is a unique identifier so if matches, the objects are equal
//         if (orcid != null && orcid.equals(that.orcid)) return true;
// 
//         // If no ORCID is present but email is the name, the objects are equal
//         if (orcid == null && uri != null && uri.equals(that.uri)) return true;
// 
//         // Default to checking all parameters
//         if (orcid != null ? !orcid.equals(that.orcid) : that.orcid != null) return false;
//         if (name != null ? !name.equals(that.name) : that.name != null) return false;
//         return uri != null ? uri.equals(that.uri) : that.uri == null;
// 
//     }
// 
//     /**
//      * ORCID is used as hashcode to fall back to comparison if missing
//      * @return The hash code for this object
//      */
//     @Override
//     public int hashCode() {
//         return orcid != null ? orcid.hashCode() : 0;
//     }
// 
// }


import org.apache.commons.codec.digest.DigestUtils;
import org.commonwl.view.researchobject.HashableAgent;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
import static org.apache.jena.ext.com.google.common.io.Files.createTempDir;
                        throw ex;
                    }
                }
                else {
                    throw ex;
                }
            }
        }

        return repo;
    }

    /**
     * Gets the commit ID of the HEAD for the given repository
     * @param repo The Git repository
     * @return The commit ID of the HEAD for the repository
     * @throws IOException If the HEAD is detached
     */
    public String getCurrentCommitID(Git repo) throws IOException {
        return repo.getRepository().findRef("HEAD").getObjectId().getName();
    }

    /**
     * Gets a set of authors for a path in a given repository
     * @param repo The git repository
     * @param path The path to get commits for
     * @return An iterable of commits
     * @throws GitAPIException Any API errors which may occur
     * @throws URISyntaxException Error constructing mailto link
     */
// Path: src/main/java/org/commonwl/view/researchobject/HashableAgent.java
// public class HashableAgent extends Agent {
// 
//     private String name;
//     private URI orcid;
//     private URI uri;
// 
//     public HashableAgent() {}
// 
//     public HashableAgent(String name, URI orcid, URI uri) {
//         this.name = name;
//         this.orcid = orcid;
//         this.uri = uri;
//     }
// 
//     @Override
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public URI getOrcid() {
//         return orcid;
//     }
// 
//     @Override
//     public void setOrcid(URI orcid) {
//         this.orcid = orcid;
//     }
// 
//     @Override
//     public URI getUri() {
//         return uri;
//     }
// 
//     @Override
//     public void setUri(URI uri) {
//         this.uri = uri;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass() || super.getClass() != o.getClass()) return false;
// 
//         HashableAgent that = (HashableAgent) o;
// 
//         // ORCID is a unique identifier so if matches, the objects are equal
//         if (orcid != null && orcid.equals(that.orcid)) return true;
// 
//         // If no ORCID is present but email is the name, the objects are equal
//         if (orcid == null && uri != null && uri.equals(that.uri)) return true;
// 
//         // Default to checking all parameters
//         if (orcid != null ? !orcid.equals(that.orcid) : that.orcid != null) return false;
//         if (name != null ? !name.equals(that.name) : that.name != null) return false;
//         return uri != null ? uri.equals(that.uri) : that.uri == null;
// 
//     }
// 
//     /**
//      * ORCID is used as hashcode to fall back to comparison if missing
//      * @return The hash code for this object
//      */
//     @Override
//     public int hashCode() {
//         return orcid != null ? orcid.hashCode() : 0;
//     }
// 
// }


// Path: src/main/java/org/commonwl/view/git/GitService.java
import org.apache.commons.codec.digest.DigestUtils;
import org.commonwl.view.researchobject.HashableAgent;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
import static org.apache.jena.ext.com.google.common.io.Files.createTempDir;

                        throw ex;
                    }
                }
                else {
                    throw ex;
                }
            }
        }

        return repo;
    }

    /**
     * Gets the commit ID of the HEAD for the given repository
     * @param repo The Git repository
     * @return The commit ID of the HEAD for the repository
     * @throws IOException If the HEAD is detached
     */
    public String getCurrentCommitID(Git repo) throws IOException {
        return repo.getRepository().findRef("HEAD").getObjectId().getName();
    }

    /**
     * Gets a set of authors for a path in a given repository
     * @param repo The git repository
     * @param path The path to get commits for
     * @return An iterable of commits
     * @throws GitAPIException Any API errors which may occur
     * @throws URISyntaxException Error constructing mailto link
     */
    public Set<HashableAgent> getAuthors(Git repo, String path) throws GitAPIException, URISyntaxException {