<commit_before>package hudson.plugins.perforce;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.TaskListener;
import hudson.model.User;
import hudson.tasks.MailAddressResolver;
import hudson.util.StreamTaskListener;
import java.io.File;

/**
 * Implementation of {@link MailAddressResolver} for looking up the email address of a user in the Perforce repository.
 *
 * @author Mike
 *         Date: Apr 22, 2008 2:01:37 PM
 */
@Extension
public class PerforceMailResolver extends MailAddressResolver {
	
    @SuppressWarnings("unchecked")
	public String findMailAddressFor(User u) {
    	
        for (AbstractProject p : Hudson.getInstance().getProjects()) {
            if (p.getScm() instanceof PerforceSCM) {
                PerforceSCM pscm = (PerforceSCM) p.getScm();
                TaskListener listener = new StreamTaskListener(System.out);
                try {
                    // I'm not sure if this is the standard way to create an ad-hoc Launcher, I just
                    // copied it from HudsonP4Executor.exec
                    FilePath workspace = p.getLastBuiltOn().createPath(p.getLastBuiltOn().getRootPath().getRemote());
                    Launcher launcher = Hudson.getInstance().createLauncher(listener);
                    com.tek42.perforce.model.User pu = pscm.getDepot(launcher, workspace).getUsers().getUser(u.getId());
                    if (pu.getEmail() != null && !pu.getEmail().equals(""))
                        return pu.getEmail();

                } catch (Exception e) {
                    listener.getLogger().println("Could not get email address from Perforce: "+e.getMessage());
                }
            }
        }
        return null;
    }

}
<commit_msg>fixing some comments in perforce mail resolver<commit_after>package hudson.plugins.perforce;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Project;
import hudson.model.TaskListener;
import hudson.model.User;
import hudson.tasks.MailAddressResolver;
import hudson.util.StreamTaskListener;
import java.io.File;

/**
 * Implementation of {@link MailAddressResolver} for looking up the email address of a user in the Perforce repository.
 *
 * @author Mike
 *         Date: Apr 22, 2008 2:01:37 PM
 */
@Extension
public class PerforceMailResolver extends MailAddressResolver {
	
    @SuppressWarnings("unchecked")
	public String findMailAddressFor(User u) {
    	
        for (AbstractProject p : Hudson.getInstance().getProjects()) {
            if (p.getScm() instanceof PerforceSCM) {
                PerforceSCM pscm = (PerforceSCM) p.getScm();
                TaskListener listener = new StreamTaskListener(System.out);
                try {
                    // TODO: replace this with p.getLastBuild().getWorkspace()
                    // which is the way it should be, but doesn't work with this version of hudson.
                    FilePath workspace = p.getLastBuiltOn().createPath(p.getLastBuiltOn().getRootPath().getRemote());
                    // I'm not sure if this is the standard way to create an ad-hoc Launcher, I just
                    // copied it from HudsonP4Executor.exec
                    Launcher launcher = Hudson.getInstance().createLauncher(listener);
                    com.tek42.perforce.model.User pu = pscm.getDepot(launcher, workspace).getUsers().getUser(u.getId());
                    if (pu.getEmail() != null && !pu.getEmail().equals(""))
                        return pu.getEmail();

                } catch (Exception e) {
                    listener.getLogger().println("Could not get email address from Perforce: "+e.getMessage());
                }
            }
        }
        return null;
    }

}

{'fraction_non_alphanumeric': 0.10057978321149483, 'fraction_numerical': 0.007058230400806655, 'mean_word_length': 2.438474870017331, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4554670', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1042, 'n_words': 280}