From db0bf9b1cf1313c6bbdb8e6e7f6334a4ce7ecb8b Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Mon, 20 Jun 2022 18:23:53 +0200 Subject: [PATCH] chore: commit save point --- application/source/files.go | 1 - application/source/issues.go | 42 +++--- application/source/requirements.go | 3 +- application/source/util.go | 4 +- development/examples/example1/req1/5/test1.md | 134 +++++++----------- 5 files changed, 82 insertions(+), 102 deletions(-) diff --git a/application/source/files.go b/application/source/files.go index 41190a6..bdb6410 100644 --- a/application/source/files.go +++ b/application/source/files.go @@ -53,7 +53,6 @@ func collectStructureFromFiles(directory string) (error, map[string]*requirement p.data.File = "." + bs p.data.Absolute = cleanedPath p.data.ToDos = findTask(content) - p.data.Yaml = p.node k := cleanedPath diff --git a/application/source/issues.go b/application/source/issues.go index ed88f4f..f3cb20d 100644 --- a/application/source/issues.go +++ b/application/source/issues.go @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "os" "strings" "time" @@ -174,35 +175,38 @@ func syncTasksWithGitlab(config *Configuration) error { context := getGitlabContext(config) searchProject(context) - //client := context.client - - //issues, response, err := client.Issues.ListProjectIssues(context.project.ID, &gitlab.ListProjectIssuesOptions{}) - //if err != nil { - // printErrorAndExit(0, "Failed to get issues %s", err.Error()) - //} - - //for _, issue := range issues { - // fmt.Println(issue.Title) - //} - //fmt.Println(response.StatusCode) - - for file, pd := range pageData { - fmt.Println(file) - //fmt.Println(pd) + for filename, pd := range pageData { buf := new(bytes.Buffer) - //pd.Yaml.Encode(buf) - var encoder = yaml.NewEncoder(buf) - err := encoder.Encode(pd.Yaml) + err := encoder.Encode(pd.OriginNode) if err != nil { return err } encoder.Close() + fmt.Println(filename) - fmt.Println(string(buf.Bytes())) + text := buf.String() + text += pd.OriginText + + info, err := os.Stat(filename) + if err != nil { + return err + } + mode := info.Mode() + + err = os.WriteFile(filename, []byte(text), mode) + if err != nil { + return err + } } return nil } + +//func replaceYaml(filename string, yaml *yaml.YAML) error { +// buf := new(bytes.Buffer) +// var encoder = yaml.NewEncoder(buf) +// err, pageData := collectStructureFromFiles(config.Path) +//} diff --git a/application/source/requirements.go b/application/source/requirements.go index ec0319a..b2b46a5 100644 --- a/application/source/requirements.go +++ b/application/source/requirements.go @@ -25,7 +25,8 @@ type requirement struct { Issues []Issue `yaml:"Issues"` // remember the node structure of yaml - Yaml *yaml.Node + OriginNode *yaml.Node + OriginText string ID string `yaml:"ID"` References []string `yaml:"References"` diff --git a/application/source/util.go b/application/source/util.go index 45ce7a1..7414611 100644 --- a/application/source/util.go +++ b/application/source/util.go @@ -14,7 +14,6 @@ import ( type contentRequirement struct { content string data requirement - node *yaml.Node } func splitYamlParts(content []byte) (error, contentRequirement) { @@ -110,7 +109,8 @@ func splitYamlParts(content []byte) (error, contentRequirement) { req := contentRequirement{} req.data = data - req.node = &node + req.data.OriginNode = &node + req.data.OriginText = text var buffer bytes.Buffer err = t.Execute(&buffer, data) diff --git a/development/examples/example1/req1/5/test1.md b/development/examples/example1/req1/5/test1.md index 0001465..d91b6aa 100644 --- a/development/examples/example1/req1/5/test1.md +++ b/development/examples/example1/req1/5/test1.md @@ -1,23 +1,15 @@ - ---- ID: ID1-22 Title: null - # Reference to other requirements References: null - # Display, Functional, Performance, Printing, Report, Testing or Validation Type: null - Alias: null - Keywords: - - Requirement - + - Requirement # First and last name of the authors as a list -Author: - - null - +Author: + - null # Proposed (The requirement has been requested by an authorized source.), # In Progress (A business analyst is actively working on crafting the requirement.), # Drafted (The initial version of the requirement has been written.), @@ -28,94 +20,78 @@ Author: # Deleted (An approved requirement has been removed from the baseline.) or # Rejected (The requirement was proposed but was never approved and is not planned for implementation in any upcoming release.) Status: "Proposed" - # Low, Medium, Hi Complexity: null # Low, Medium, Hi Difficulty: null # Nice to have, Low, Medium, Hi or Blocker -Priority: null +Priority: null Version: 0.0.1 Milestone: null - # 0 (means that a task has already been completed), 1 (is a very small task), 2, 3, 5 (are rather smaller tasks), # 8, 13, 20, 40, 100 Estimation: 40 - # The time required for this requirement # Valid time units are “nsâ€, “us†(or “µsâ€), “msâ€, “sâ€, “mâ€, “hâ€. -Time Spent: 5h - +Time Spent: 5h # who is the source of the demand Source: null Created: 2022-05-03 Last Update: null - # the individual items as a list Items: - - ID: null - Name: null - # what is it, a image, font, legal information, access data, texts, decisions, etc. - Type: null - # does this belong to a group - Group: null - Description: null - Delivery until: null - # when was the project items delivered and by whom? - Provided on: null - Provided by: null - + - ID: null + Name: null + # what is it, a image, font, legal information, access data, texts, decisions, etc. + Type: null + # does this belong to a group + Group: null + Description: null + Delivery until: null + # when was the project items delivered and by whom? + Provided on: null + Provided by: null # https://gdpr-info.eu/art-30-gdpr/ Privacy: - - ID: null - - # Purpose of the data processing, - # for example, shipping an order and handing it over to a shipping service provider. - Purposes: null - - # More detailed description of the reason and process of data processing. - Description: null - - # Who is responsible for data protection - Contact: null - - # But working with these categories might end up being a bad idea since doing so might - # mean packing different things into one. This leads to either oversimplifications or - # a lot of specifications within a category. It might be advisable to split some of them - # up or to add additional ones to make them fit your business reality. - # Examples: Employees, Suppliers, Customers, Job applicants, Consultants, Visitors, Prospects, Contractors, Trainees - Affected Groups: null - - # - Category: - - # Example: 5 years from the payment of the salary - Data Retention Period: null - - # On what legal basis is the data collected - # Special legal regulation outside the GDPR - # Consent of the data subject (Art. 6 para. 1 a) DSG-VO) use Consent field - # Collective agreement (e.g. company agreement, collective agreement) - # Establishment, performance or termination of an employment relationship (nationally regulated in the BDSG) - # Contract or initiation of a contract with the data subject (Art. 6 para. 1 b) DSG-VO.) - # Balancing of interests (Art. 6 para. 1 f) DSG-VO): Please name the overriding interests - Legal Basis: null - - # “Consent†of the data subject refers to any freely given specific, informed and unambiguous indication of his or - # her wishes in the form of a statement or other unambiguous affirmative act by which the data subject signifies - # his or her agreement to personal data relating to him or her being processed. - Consent: null - - # Where applicable, transfers of personal data to a third country or an international organisation, including - # the identification of that third country or international organisation and, in the case of transfers referred - # to in the second subparagraph of Article 49(1), the documentation of suitable safeguards; - Transfers: - - # Where possible, a general description of the technical and organisational - # security measures referred to in Article 32(1). - TOM: null - -... + - ID: null + # Purpose of the data processing, + # for example, shipping an order and handing it over to a shipping service provider. + Purposes: null + # More detailed description of the reason and process of data processing. + Description: null + # Who is responsible for data protection + Contact: null + # But working with these categories might end up being a bad idea since doing so might + # mean packing different things into one. This leads to either oversimplifications or + # a lot of specifications within a category. It might be advisable to split some of them + # up or to add additional ones to make them fit your business reality. + # Examples: Employees, Suppliers, Customers, Job applicants, Consultants, Visitors, Prospects, Contractors, Trainees + Affected Groups: null + # + Category: + # Example: 5 years from the payment of the salary + Data Retention Period: null + # On what legal basis is the data collected + # Special legal regulation outside the GDPR + # Consent of the data subject (Art. 6 para. 1 a) DSG-VO) use Consent field + # Collective agreement (e.g. company agreement, collective agreement) + # Establishment, performance or termination of an employment relationship (nationally regulated in the BDSG) + # Contract or initiation of a contract with the data subject (Art. 6 para. 1 b) DSG-VO.) + # Balancing of interests (Art. 6 para. 1 f) DSG-VO): Please name the overriding interests + Legal Basis: null + # “Consent†of the data subject refers to any freely given specific, informed and unambiguous indication of his or + # her wishes in the form of a statement or other unambiguous affirmative act by which the data subject signifies + # his or her agreement to personal data relating to him or her being processed. + Consent: null + # Where applicable, transfers of personal data to a third country or an international organisation, including + # the identification of that third country or international organisation and, in the case of transfers referred + # to in the second subparagraph of Article 49(1), the documentation of suitable safeguards; + Transfers: + # Where possible, a general description of the technical and organisational + # security measures referred to in Article 32(1). + TOM: null + + ### {{ .Title }} - {{ .ID }} -- GitLab