Check that RevisionStrings are properly formatted.
@param fullBuildString
@return build revision # (SVN), build hash (git) or null
763718
public static String parseRevisionString(String fullBuildString) {
        String build = "";

        // Test for SVN revision string - example: https://svn.voltdb.com/eng/trunk?revision=2352
        String[] splitted = fullBuildString.split("=", 2);
        if (splitted.length == 2) {
            build = splitted[1].trim();
            if (build.length() == 0) {
                return null;
            }
            return build;

        }

        // Test for git build string - example: 2.0 voltdb-2.0-70-gb39f43e-dirty
        Pattern p = Pattern.compile("-(\\d*-\\w{8}(?:-.*)?)");
        Matcher m = p.matcher(fullBuildString);
        if (! m.find()) {
            return null;
        }
        build = m.group(1).trim();
        if (build.length() == 0) {
            return null;
        }
        return build;
    }
565669
private String extractVersionFromFullVersion(String pFullVersion) {
        if (pFullVersion != null) {
            Matcher matcher = GLASSFISH_VERSION.matcher(pFullVersion);
            if (matcher.matches()) {
                serverName = GLASSFISH_NAME;
                vendorName = GLASSFISH_VENDOR_NAME;
                return matcher.group(1);
            }
            matcher = PAYARA_VERSION.matcher(pFullVersion);
            if (matcher.matches()) {
                serverName = PAYARA_NAME;
                vendorName = PAYARA_VENDOR_NAME;
                return matcher.group(1);
            }
        }
        return null;
    }
1130148
function(bin, full) {
      var url = [];

      if (bin.url) {
        url.push(bin.url);

        if (bin.revision) {
          url.push(bin.revision);
        }
      }

      return this.url(url.join('/'), full);
    }
1343659
@Override
    @InterfaceAudience.Public
    public Map<String, Object> getProperties() {
        Map<String, Object> properties = revisionInternal.getProperties();
        if (!checkedProperties) {
            if (properties == null) {
                if (loadProperties() == true) {
                    properties = revisionInternal.getProperties();
                }
            }
            checkedProperties = true;
        }
        return properties != null ? Collections.unmodifiableMap(properties) : null;
    }
1005112
public static String getDefaultCompilerId( String sbtVersion, String playVersion )
    {
        String result = null;
        if ( sbtVersion != null && !sbtVersion.isEmpty() )
        {
            if ( sbtVersion.equals( "0.13" ) || sbtVersion.startsWith( "0.13." ) )
            {
                result = "sbt013";
            }
            else if ( sbtVersion.equals( "0.12" ) || sbtVersion.startsWith( "0.12." ) )
            {
                result = "sbt012";
            }
        }
        if ( result == null )
        {
            if ( playVersion != null && !playVersion.isEmpty() )
            {
                if ( playVersion.startsWith( "2.1." ) || playVersion.startsWith( "2.1-" ) )
                {
                    result = "sbt012";
                }
            }
        }
        if ( result == null )
        {
            result = "sbt013"; // use latest version
        }
        return result;
    }
76399
protected void pullBulkWithAllDocs(final List<RevisionInternal> bulkRevs) {
        // http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API

        ++httpConnectionCount;
        final RevisionList remainingRevs = new RevisionList(bulkRevs);

        Collection<String> keys = CollectionUtils.transform(bulkRevs,
                new CollectionUtils.Functor<RevisionInternal, String>() {
                    public String invoke(RevisionInternal rev) {
                        return rev.getDocID();
                    }
                }
        );

        Map<String, Object> body = new HashMap<String, Object>();
        body.put("keys", keys);

        Future future = sendAsyncRequest("POST",
                "_all_docs?include_docs=true",
                body,
                new RemoteRequestCompletion() {

                    public void onCompletion(RemoteRequest remoteRequest, Response httpResponse, Object result, Throwable e) {

                        Map<String, Object> res = (Map<String, Object>) result;

                        if (e != null) {
                            setError(e);

                            // TODO: There is a known bug caused by the line below, which is
                            // TODO: causing testMockSinglePullCouchDb to fail when running on a Nexus5 device.
                            // TODO: (the batching behavior is different in that case)
                            // TODO: See https://github.com/couchbase/couchbase-lite-java-core/issues/271
                            // completedChangesCount.addAndGet(bulkRevs.size());

                        } else {
                            // Process the resulting rows' documents.
                            // We only add a document if it doesn't have attachments, and if its
                            // revID matches the one we asked for.
                            List<Map<String, Object>> rows = (List<Map<String, Object>>) res.get("rows");
                            Log.v(TAG, "%s checking %d bulk-fetched remote revisions", this, rows.size());
                            for (Map<String, Object> row : rows) {
                                Map<String, Object> doc = (Map<String, Object>) row.get("doc");
                                if (doc != null && doc.get("_attachments") == null) {
                                    RevisionInternal rev = new RevisionInternal(doc);
                                    RevisionInternal removedRev = remainingRevs.removeAndReturnRev(rev);
                                    if (removedRev != null) {
                                        rev.setSequence(removedRev.getSequence());
                                        queueDownloadedRevision(rev);
                                    }
                                } else {
                                    Status status = statusFromBulkDocsResponseItem(row);
                                    if (status.isError() && row.containsKey("key") && row.get("key") != null) {
                                        RevisionInternal rev = remainingRevs.revWithDocId((String) row.get("key"));
                                        if (rev != null) {
                                            remainingRevs.remove(rev);
                                            revisionFailed(rev, new CouchbaseLiteException(status));
                                        }
                                    }

                                }
                            }
                        }

                        // Any leftover revisions that didn't get matched will be fetched individually:
                        if (remainingRevs.size() > 0) {
                            Log.v(TAG,
                                    "%s bulk-fetch didn't work for %d of %d revs; getting individually",
                                    this, remainingRevs.size(), bulkRevs.size());
                            for (RevisionInternal rev : remainingRevs) {
                                queueRemoteRevision(rev);
                            }
                            pullRemoteRevisions();
                        }

                        --httpConnectionCount;
                        // Start another task if there are still revisions waiting to be pulled:
                        pullRemoteRevisions();
                    }
                });
        pendingFutures.add(future);
    }
1278851
static String getServiceFromBuildName(String buildName) {
        if (null == buildName || buildName.isEmpty()) {
            return buildName;
        }

        return buildName.substring(0, buildName.lastIndexOf('-'));
    }
1157360
public String buildAsHex(BuilderMode builderMode) {
        byte[] ret = build(builderMode);
        if (Validator.isEmpty(ret)) {
            return null;
        }
        return DatatypeConverter.printHexBinary(ret);
    }
433547
protected function get_full_version_string($versionString) {
		if(strlen($versionString)) {
			$bits = $this->parse_version_string($versionString);
			
			$fullVersion = $bits['version_major'] .'.'. $bits['version_minor'] .'.'.
					$bits['version_maintenance'];
			if(strlen($bits['version_suffix'])) {
				$fullVersion .= '-'. $bits['version_suffix'];
			}
		}
		else {
			$this->error_handler(__METHOD__ .": no version string given");
		}
		
		return($fullVersion);
	}
1071908
private void addChangeSets(Build build, JSONObject buildJson) {
        JSONObject changeSet = (JSONObject) buildJson.get("changes");

//        Map<String, String> revisionToUrl = new HashMap<>();

//        // Build a map of revision to module (scm url). This is not always
//        // provided by the Bamboo API, but we can use it if available.
//        for (Object revision : getJsonArray(changeSet, "revisions")) {
//            JSONObject json = (JSONObject) revision;
//            revisionToUrl.put(json.get("revision").toString(), getString(json, "module"));
//        }

        for (Object item : getJsonArray(changeSet, "change")) {
            JSONObject jsonItem = (JSONObject) item;
            SCM scm = new SCM();
            scm.setScmAuthor(getString(jsonItem, "author"));
            scm.setScmCommitLog(getString(jsonItem, "comment"));
            scm.setScmCommitTimestamp(getCommitTimestamp(jsonItem));
            scm.setScmRevisionNumber(getRevision(jsonItem));
            scm.setScmUrl(getString(jsonItem,"commitUrl"));
            scm.setNumberOfChanges(getJsonArray((JSONObject)jsonItem.get("files"), "file").size());
            build.getSourceChangeSet().add(scm);
        }
    }
1159259
public File getBuildDir() {
        // we use the null check variant so that people can write true unit tests with a mock ItemParent
        // and without a JenkinsRule. Such tests are of limited utility as there is a high risk of hitting
        // some code that needs the singleton, but for persistence migration test cases it makes sense to permit
        Jenkins j = Jenkins.getInstanceOrNull();
        if (j == null) {
            return new File(getRootDir(), "builds");
        }
        return j.getBuildDirFor(this);
    }
706365
public com.google.protobuf.ByteString
      getVersionUrlBytes() {
    java.lang.Object ref = versionUrl_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      versionUrl_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
1069882
@Get("regex:/projects/(?<projectName>[^/]+)/repos/(?<repoName>[^/]+)/list(?<path>(|/.*))$")
    public CompletableFuture<List<EntryDto<?>>> listFiles(@Param("path") String path,
                                                          @Param("revision") @Default("-1") String revision,
                                                          Repository repository) {
        final String normalizedPath = normalizePath(path);
        final Revision normalizedRev = repository.normalizeNow(new Revision(revision));
        final CompletableFuture<List<EntryDto<?>>> future = new CompletableFuture<>();
        listFiles(repository, normalizedPath, normalizedRev, false, future);
        return future;
    }
480818
def get_final_version_string(release_mode, semver, commit_count=0):
    """"""
    version_string = ".".join(semver)
    maybe_dev_version_string = version_string
    updates = {}
    if release_mode:
        # in production, we have something like `1.2.3`, as well as a flag e.g. PRODUCTION=True
        updates[Constants.RELEASE_FIELD] = config.RELEASED_VALUE
    else:
        # in dev mode, we have a dev marker e.g. `1.2.3.dev678`
        maybe_dev_version_string = config.DEVMODE_TEMPLATE.format(
            version=version_string, count=commit_count
        )

    # make available all components of the semantic version including the full string
    updates[Constants.VERSION_FIELD] = maybe_dev_version_string
    updates[Constants.VERSION_STRICT_FIELD] = version_string
    return updates
1119087
@RequestMapping(value = "configuration/{configuration:.*}/revision/{revision}", method = RequestMethod.GET)
    public Resource<OntrackSVNRevisionInfo> revisionInfo(@PathVariable String configuration, @PathVariable long revision) {
        return Resource.of(
                svnInfoService.getOntrackRevisionInfo(
                        svnService.getRepository(configuration),
                        revision
                ),
                uri(on(getClass()).revisionInfo(configuration, revision))
        ).withView(Build.class);
    }
28648
public static String getBuildVersion(){
    return VersionInfo.getVersion() + 
    " from " + VersionInfo.getRevision() +
    " by " + VersionInfo.getUser() + 
    " on " + VersionInfo.getDate();
  }
264263
public String buildRevision(final String previousRevision)
	{

		HashMap<String, String> bufferMap = new HashMap<String, String>();

		StringBuilder output = new StringBuilder();
		if (previousRevision != null) {
			output.append(previousRevision);
		}

		int size = parts.size();
		DiffPart part;

		for (int i = 0; i < size; i++) {

			part = parts.get(i);

			switch (part.getAction()) {
			case FULL_REVISION_UNCOMPRESSED:
				output = new StringBuilder();
				output.insert(0, part.getText());
				break;
			case INSERT:
				output.insert(part.getStart(), part.getText());
				break;
			case DELETE:
				output.delete(part.getStart(), part.getEnd());
				break;
			case REPLACE:
				output.replace(part.getStart(), part.getEnd(), part.getText());
				break;
			case CUT:
				bufferMap.put(part.getText(),
						output.substring(part.getStart(), part.getEnd()));
				output.delete(part.getStart(), part.getEnd());
				break;
			case PASTE:
				output.insert(part.getStart(), bufferMap.remove(part.getText()));
				break;
			default:
				throw new RuntimeException("UNKNOWN PART ACTION");
			}
		}

		return output.toString();
	}