Test if a brach is the current one
@param branch
@returns {Function}
344465
function isCurrentBranch( branch ) {
      return function() {
        var deferred = Q.defer();

        Q.fcall(command('git symbolic-ref --short -q HEAD', 'Get current branch'))
          .then(function( data ) {
            //console.log('data=',data);
            if ( data && data.trim() === branch ) {
              deferred.resolve(true);
            }
            else {
              throw new Error(format('Error. Branch [%s] is not the current branch. Output:[%s]', branch, data.trim()));
            }
          })
          .catch(function( err ) {
            console.log('err=',err);
            deferred.reject(err);
          });
        return deferred.promise;
      };
    }
1152779
def branch(version = Origen.app.version.prefixed)
      version = VersionString.new(version)
      version = version.prefixed if version.semantic?
      capture = false
      File.readlines("#{Origen.root}/doc/history").each do |line|
        line = line.strip
        if capture
          if capture && line =~ /^#+ .*(Selector|Branch): '(.*)'/
            return Regexp.last_match(2).gsub('\\', '')
          end
        else
          if line =~ /Tag:/
            line = line.gsub('\\', '')
            if line =~ /^#+ Tag: #{version}$/ ||
               line =~ />Tag: #{version}</
              capture = true
            end
          end
        end
      end
      nil
    end
464808
def is_remote_branch?(branch)
      branch_names = self.branches.remote.map {|b| b.name}
      branch_names.include?(branch)
    end
580245
function NullInPathError() {
    var instance = new Error("`null` and `undefined` are not allowed in branch key positions");

    instance.name = "NullInPathError";

    if (Object.setPrototypeOf) {
        Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
    }

    if (Error.captureStackTrace) {
        Error.captureStackTrace(instance, NullInPathError);
    }

    return instance;
}
1212215
private boolean isCurrentBackup(File log)
   {
      for (BackupChain chain : currentBackups)
      {
         if (log.getName().equals(new File(chain.getLogFilePath()).getName()))
         {
            return true;
         }
      }

      return false;
   }
505051
async function getBranchStatus(branchName, requiredStatusChecks) {
  logger.debug(
    `getBranchStatus(${branchName}, requiredStatusChecks=${!!requiredStatusChecks})`
  );

  if (!requiredStatusChecks) {
    // null means disable status checks, so it always succeeds
    logger.debug('Status checks disabled = returning "success"');
    return 'success';
  }

  const branchCommit = await config.storage.getBranchCommit(branchName);

  try {
    const commitStatus = (await api.get(
      `./rest/build-status/1.0/commits/stats/${branchCommit}`
    )).body;

    logger.debug({ commitStatus }, 'branch status check result');

    if (commitStatus.failed > 0) return 'failed';
    if (commitStatus.inProgress > 0) return 'pending';
    return commitStatus.successful > 0 ? 'success' : 'pending';
  } catch (err) {
    logger.warn({ err }, `Failed to get branch status`);
    return 'failed';
  }
}
1082970
function getCurrentBranch(verbose) {
  return Promise.resolve()
    .then(execCmd.bind(null,
      'git',
      ['symbolic-ref', 'HEAD', '-q'],
      'problem getting current branch',
      verbose
    ))
    .catch(function() {
      return '';
    })
    .then(function(result) {
      return result.replace(new RegExp('^refs\/heads\/'), '');
    });
}
1281589
def is_current(self, paths=None):
        """'"""
        version = self.get_version(paths)
        if version is None:
            return False
        return self.version_ok(version)
106064
def _git_enable_branch(desired_branch):
    """"""
    preserved_branch = _git_get_current_branch()
    try:
        if preserved_branch != desired_branch:
            _tool_run('git checkout ' + desired_branch)
        yield
    finally:
        if preserved_branch and preserved_branch != desired_branch:
            _tool_run('git checkout ' + preserved_branch)
1259286
async function getBranchStatusCheck(branchName, context) {
  logger.debug(`getBranchStatusCheck(${branchName}, context=${context})`);

  const branchCommit = await config.storage.getBranchCommit(branchName);

  try {
    const states = await utils.accumulateValues(
      `./rest/build-status/1.0/commits/${branchCommit}`
    );

    for (const state of states) {
      if (state.key === context) {
        switch (state.state) {
          case 'SUCCESSFUL':
            return 'success';
          case 'INPROGRESS':
            return 'pending';
          case 'FAILED':
          default:
            return 'failure';
        }
      }
    }
  } catch (err) {
    logger.warn({ err }, `Failed to check branch status`);
  }
  return null;
}
667247
function hasGit(){
		var checkGit;
		try {
			which.sync('git');
			checkGit = true;
		} catch (ex) {
			checkGit = false;
		}
		return checkGit;
	}
434571
def get_current_branch(self, location):
        
        # git-symbolic-ref exits with empty stdout if "HEAD" is a detached
        # HEAD rather than a symbolic ref.  In addition, the -q causes the
        # command to exit with status code 1 instead of 128 in this case
        # and to suppress the message to stderr.
        args = ['symbolic-ref', '-q', 'HEAD']
        output = self.run_command(
            args, extra_ok_returncodes=(1, ), show_stdout=False, cwd=location,
        )
        ref = output.strip()

        if ref.startswith('refs/heads/'):
            return ref[len('refs/heads/'):]

        return None
190133
def _check_branch(self, revision, branch):
        '''
        
        '''

        # Get a changelog
        clog_url = self.hg_url / branch / 'json-log' / revision
        try:
            Log.note("Searching through changelog {{url}}", url=clog_url)
            clog_obj = http.get_json(clog_url, retry=RETRY)
            if isinstance(clog_obj, (text_type, str)):
                Log.note(
                    "Revision {{cset}} does not exist in the {{branch}} branch",
                    cset=revision, branch=branch
                )
                return False
        except Exception as e:
            Log.note("Unexpected error getting changset-log for {{url}}: {{error}}", url=clog_url, error=e)
            return False
        return True
725355
public static boolean branchExists(String branch, String baseUrl) {
        CommandLine cmdLine = new CommandLine(SVN_CMD);
        cmdLine.addArgument(CMD_LOG);
        cmdLine.addArgument(OPT_XML);
        addDefaultArguments(cmdLine, null, null);
        cmdLine.addArgument("-r");
        cmdLine.addArgument("HEAD:HEAD");
        cmdLine.addArgument(baseUrl + branch);

        try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) {
            return true;
        } catch (IOException e) {
            log.log(Level.FINE, "Branch " + branch + " not found or other error", e);
            return false;
        }
    }
804451
public boolean isBranch()
  {
    switch (getOpcode()) {
    case IFNULL:
    case IFNONNULL:
    case IFNE:
    case IFEQ:
    case IFLT:
    case IFGE:
    case IFGT:
    case IFLE:
    case IF_ICMPEQ:
    case IF_ICMPNE:
    case IF_ICMPLT:
    case IF_ICMPGE:
    case IF_ICMPGT:
    case IF_ICMPLE:
    case IF_ACMPEQ:
    case IF_ACMPNE:
    case JSR:
    case JSR_W:
    case GOTO:
    case GOTO_W:
      return true;
    }

    return false;
  }
765603
def assert_on_branch(branch_name):
    # type: (str) -> None
    
    branch = git.current_branch(refresh=True)

    if branch.name != branch_name:
        if context.get('pretend', False):
            log.info("Would assert that you're on a <33>{}<32> branch",
                     branch_name)
        else:
            log.err("You're not on a <33>{}<31> branch!", branch_name)
            sys.exit(1)
359109
function checkKeyExists(key) {
    var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fallback';
    // get the current language from the store
    var locale = store.state[moduleName].locale;
    var fallback = store.state[moduleName].fallback;
    var translations = store.state[moduleName].translations; // check the current translation

    if (translations.hasOwnProperty(locale) && translations[locale].hasOwnProperty(key)) {
      return true;
    }

    if (scope == 'strict') {
      return false;
    } // check any localized translations


    var localeRegional = locale.split('-');

    if (localeRegional.length > 1 && translations.hasOwnProperty(localeRegional[0]) && translations[localeRegional[0]].hasOwnProperty(key)) {
      return true;
    }

    if (scope == 'locale') {
      return false;
    } // check if a fallback locale exists


    if (translations.hasOwnProperty(fallback) && translations[fallback].hasOwnProperty(key)) {
      return true;
    } // key does not exist in the store


    return false;
  }